Expand my Community achievements bar.

Unable to connect to CRX Server using JCR/JackRabbit

Avatar

Level 1

I am trying to access a CRX server over the internet using JcrUtils.getRepository method in JCR/JackRabbit and receiving the following error:

javax.jcr.RepositoryException: Unable to access a repository with the following settings:
  org.apache.jackrabbit.repository.uri: http://<<Server Name>>/crx/server
The following RepositoryFactory classes were consulted:
Perhaps the repository you are trying to access is not available at the moment.
at org.apache.jackrabbit.commons.JcrUtils.getRepository(JcrUtils.java:184)
at org.apache.jackrabbit.commons.JcrUtils.getRepository(JcrUtils.java:223)
at ReadContentRepositary.main(ReadContentRepositary.java:19)
 

This is my code:

import javax.jcr.Repository;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
import javax.jcr.Node;
import org.apache.jackrabbit.*;

import org.apache.jackrabbit.commons.JcrUtils;
import org.apache.jackrabbit.core.TransientRepository;

public class ReadContentRepositary {

public static void main(String[] args) {
// TODO Auto-generated method stub

try { 
//Create a connection to the CQ repository running on local host
Repository repository = JcrUtils.getRepository("http://<<Server Name>>/crx/server");

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

//Create a node that represents the root node
Node root = session.getRootNode();
System.out.println("Root Node Value is " + root.getIndex());

// Save the session changes and log out
//session.save();
session.logout();
}
catch(Exception e){
e.printStackTrace();
}
}

} 

2 Replies

Avatar

Level 3

Hi,

What version of AEM are you using?

Did you check the WebDav bundles on the target AEM server? Remote access is dependent on the WebDav configuration. The code seems alright to me, however this is reminiscent of CQ 5.X.

Please check and let me know.

Thank you

Varun