Unable to connect to CRX Server using JCR/JackRabbit | Community
Skip to main content
Paramesh
February 1, 2016
Question

Unable to connect to CRX Server using JCR/JackRabbit

  • February 1, 2016
  • 2 replies
  • 3574 views

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();
}
}

} 

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

2 replies

varunmitra
Adobe Employee
Adobe Employee
February 2, 2016

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

varunmitra
Adobe Employee
Adobe Employee
February 2, 2016