Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Not able access AEM author using JcrUtils.getRepository

Avatar

Level 1

I want to access one author crx from another author CRX. For example, I am trying to make a connection from Dev author to QA author. I am using JCRUtil class to access the repository. Below is a code snippet

It is throwing below exception -

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:

org.apache.jackrabbit.commons.JndiRepositoryFactory: declined 

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

I went through some article and forum and it suggested to add below dependency.

org.apache.jackrabbit

jackrabbit-jcr2dav

2.6.0

Even after adding above dependency it is working. Can you please let me if I am missing something or is there another way to make the connection between two author instance?

Thank you

5 Replies

Avatar

Community Advisor

Hi satish

Please make sure the following thing:

1. The QA author environment should be up and running.

2. From your example, you have pointed it to localhost in code.It will work if dev author & QA author is on the same machine otherwise you have to give appropriate IP url.

Also,Could you please try the below:

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

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

//Create a Session- put a valid creds who has the access of the repository

javax.jcr.Session session = repository.login( new SimpleCredentials("admin", "admin".toCharArray()));

//Create a node that represents the root node

Node root = session.getRootNode();

Please refer: How to programmatically access the AEM JCR

Avatar

Level 1

Hi Arpit,

Thank you for your reply.

I understand QA should be up and running.

I have localhost because I have given you the sample code that I have used.

I have used the code that you mentioned but It is not working.  To test I have created to author instance on diff port in my locale try to access one author from another instance.

Hope this clears your doubt.

Is the code working for you in the scenario I have mentioned?

Avatar

Level 3

This can also be network issue. are you able to ping your qa server from dev server?

Avatar

Level 3

You can also invoke AEM server B from server A via a Servlet. 

Avatar

Level 3

Get Repository API is generally used to connect to the instance from a standalone web application to do content creation/updates. Where are you executing this piece of code. Inside a servlet or a service? What is your actual requirement to connect from one environment to other? If you are looking for content sync, there are multiple options like using package manager or Grabbit etc..