내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

Remote Repository Session

Avatar

이전 커뮤니티 멤버

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?

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Level 10

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 답변 개

Avatar

Level 10

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

Avatar

이전 커뮤니티 멤버

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

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

Avatar

정확한 답변 작성자:
Level 10

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.