2 Replies Latest reply on Feb 2, 2016 9:57 AM by varunmitra

    Unable to connect to CRX Server using JCR/JackRabbit

    Paramesh

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

      }