Remote Repository Session | Adobe Higher Education
Skip to main content
October 16, 2015
Respondido

Remote Repository Session

  • October 16, 2015
  • 3 respostas
  • 1543 Visualizações

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?

Este tópico foi fechado para respostas.
Melhor resposta por 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 Respostas

smacdonald2008
Level 10
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. 

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
Level 10
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