Remote Repository Session | Community
Skip to main content
October 16, 2015
Solved

Remote Repository Session

  • October 16, 2015
  • 3 replies
  • 1533 views

I want to create a remote session to another repository from within a repository, means I have a servlet running inside a CQ5 author instance. I tried to open a connection to a remote repository with JcrUtils:

Repository repository = JcrUtils.getRepository( "http://myhost:4502/crx/server" );

This causes an error message:

javax.jcr.RepositoryException: Unable to access a repository with the following settings:

org.apache.jackrabbit.repository.uri: http://localhost:4502/crx/server

The following RepositoryFactory classes were consulted:

Perhaps the repository you are trying to access is not available at the moment.

any ideas?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

I am not sure that writing an OSGi bundle that contains JCR API app logic to connect to another JCR repository is a supported use case.  

If that was the case -- this Java code would be supported code from within an OSGi bundle:

//Create a connection to the CQ repository running on local host

Repository repository = JcrUtils.getRepository(aemUrl);

 

//Create a Session

Javax.jcr.Session session = repository.login( new SimpleCredentials("readonly", "readonly".toCharArray()));

 

However - this JCR API code is only supported from outside of the CRX layer. For example -- an external Java app such as  a Java Swing app. 

3 replies

smacdonald2008
New Participant
October 16, 2015

You cannot run this code from within an OSGi bundle.  

//Create a connection to the CQ repository running on local host

Repository repository = JcrUtils.getRepository(aemUrl);

 

//Create a Session

Javax.jcr.Session session = repository.login( new SimpleCredentials("readonly", "readonly".toCharArray()));

 

You use this code from a standalone Java app -- such as:

http://scottsdigitalcommunity.blogspot.ca/2013/11/developing-java-swing-application-that.html

To run JCR API code from within an OSGi bundle, see:

http://helpx.adobe.com/experience-manager/using/querying-experience-manager-data-using1.html

To create a session from within an OSGI  -- you use this code:

//Invoke the adaptTo method to create a Session used to create a QueryManager

 ResourceResolver resourceResolver = resolverFactory.getAdministrativeResourceResolver(null);

session = resourceResolver.adaptTo(Session.class);

And the repository that you use from within an OSGi is localhost.

Hope this helps

October 16, 2015

I tried already a local connection, this works, of course.

My problem is to connect from within a repository to another one...

smacdonald2008
smacdonald2008Accepted solution
New Participant
October 16, 2015

I am not sure that writing an OSGi bundle that contains JCR API app logic to connect to another JCR repository is a supported use case.  

If that was the case -- this Java code would be supported code from within an OSGi bundle:

//Create a connection to the CQ repository running on local host

Repository repository = JcrUtils.getRepository(aemUrl);

 

//Create a Session

Javax.jcr.Session session = repository.login( new SimpleCredentials("readonly", "readonly".toCharArray()));

 

However - this JCR API code is only supported from outside of the CRX layer. For example -- an external Java app such as  a Java Swing app.