Hi,
I'm trying to connect to the JCR from a Java application, but the CQ5 instance has Apache Sling Simple WebDAV Access to repositories and Apache Sling DavEx Access to repositories turned off in the OSGi console. If these are turned on, I can successfully use the following code:
repository = JcrUtils.getRepository( "http://123.123.123.123:4502/crx/server" );
session = repository.login( new SimpleCredentials( "admn", "admin".toCharArray( ) ) );
All is lovely, and I get a valid session returned. But in production, when WebDAV is turned off, I get the following warnings when trying jcrUtils.getRepository:
[main] INFO org.apache.commons.httpclient.auth.AuthChallengeProcessor - basic authentication scheme selected
[main] INFO org.apache.commons.httpclient.HttpMethodDirector - No credentials available for BASIC 'Sling (Development)'@123.123.123.123:4502
[main] WARN org.apache.jackrabbit.spi2dav.RepositoryServiceImpl - Authentication required to access repository descriptors
and then this exception when trying to get the session:
javax.jcr.nodetype.ConstraintViolationException: Method Not Allowed
at org.apache.jackrabbit.spi2dav.ExceptionConverter.generate(ExceptionConverter.java:105)
at org.apache.jackrabbit.spi2dav.ExceptionConverter.generate(ExceptionConverter.java:51)
at org.apache.jackrabbit.spi2dav.ExceptionConverter.generate(ExceptionConverter.java:45)
at org.apache.jackrabbit.spi2dav.RepositoryServiceImpl.obtain(RepositoryServiceImpl.java:782 )
at org.apache.jackrabbit.spi2dav.RepositoryServiceImpl.obtain(RepositoryServiceImpl.java:726 )
at org.apache.jackrabbit.spi2davex.RepositoryServiceImpl.obtain(RepositoryServiceImpl.java:3 01)
at org.apache.jackrabbit.jcr2spi.RepositoryImpl.login(RepositoryImpl.java:151)
at org.apache.jackrabbit.commons.AbstractRepository.login(AbstractRepository.java:123)
at au.com.btes.cq.CQServer.connectToRepository(CQServer.java:746)
at au.com.btes.cq.CQServer.updateOSGiConfiguration(CQServer.java:543)
at au.com.btes.cq.CQServer.updateOSGiConfigurations(CQServer.java:521)
at au.com.btes.cq.deployer.CQDeployer.configureOSGi(CQDeployer.java:494)
at au.com.btes.cq.deployer.CQDeployer.startDeployment(CQDeployer.java:186)
at au.com.btes.cq.deployer.Main.main(Main.java:13)
Caused by: org.apache.jackrabbit.webdav.DavException: Method Not Allowed
at org.apache.jackrabbit.webdav.client.methods.DavMethodBase.getResponseException(DavMethodB ase.java:165)
at org.apache.jackrabbit.webdav.client.methods.DavMethodBase.getResponseBodyAsMultiStatus(Da vMethodBase.java:91)
at org.apache.jackrabbit.spi2dav.RepositoryServiceImpl.obtain(RepositoryServiceImpl.java:754 )
... 10 more
WebDEV is not enabled, so fair enough. So based on the documentation at http://dev.day.com/docs/en/crx/current/developing/accessing_the_crx.html, I then tried an RMI connection with the following:
repository = JcrUtils.getRepository( "rmi://123.123.123.123:4502/crx" );
session = repository.login( new SimpleCredentials( "admn", "admin".toCharArray( ) ) );
When it hits the line getting the repo, it waits for about 30 seconds, then returns with:
javax.jcr.RepositoryException: Unable to access a repository with the following settings:
org.apache.jackrabbit.repository.uri: rmi://123.123.123.123:4502/crx
The following RepositoryFactory classes were consulted:
org.apache.jackrabbit.commons.JndiRepositoryFactory: declined
org.apache.jackrabbit.jcr2dav.Jcr2davRepositoryFactory: declined
org.apache.jackrabbit.jcr2spi.Jcr2spiRepositoryFactory: declined
org.apache.jackrabbit.rmi.repository.RmiRepositoryFactory: failed
because of RepositoryException: Failed to look up the RMI resource //123.123.123.123:4502/crx
because of ConnectIOException: error during JRMP connection establishment; nested exception is:
java.io.EOFException
because of EOFException: null
Perhaps the repository you are trying to access is not available at the moment.
It does not even try and get the session, as it failed on the retreiving of the repository.
Is there some setting on CQ5/CRX that needs to be applied to enable RMI connections? If so, what are the security (or other) ramifications of turning it on? If there's no setting, then can anyone see where I'm going wrong here?
Thanks for the help,
K