Error on connecting to JCR using JcrUtils.getRepositor | Community
Skip to main content
Level 6
October 16, 2015
Solved

Error on connecting to JCR using JcrUtils.getRepositor

  • October 16, 2015
  • 2 replies
  • 3252 views

The call to Node root = session.getRootNode(); 

 

gives me the following error. Which I have been unble to resolve

 

 


Exception in thread "main" javax.jcr.RepositoryException: Unable to access a repository with the following settings:
    org.apache.jackrabbit.repository.uri: rmi://localhost:4502/crx/server
The following RepositoryFactory classes were consulted:
    org.apache.jackrabbit.jcr2dav.Jcr2davRepositoryFactory: declined
    org.apache.jackrabbit.jcr2spi.Jcr2spiRepositoryFactory: declined
    org.apache.jackrabbit.rmi.repository.RmiRepositoryFactory: failed
        because of RepositoryException: Failed to look up the RMI resource //localhost:4502/crx/server
        because of ConnectIOException: error during JRMP connection establishment; nested exception is: 
    java.io.EOFException
        because of EOFException: null
    org.apache.jackrabbit.core.RepositoryFactoryImpl: declined
    org.apache.jackrabbit.commons.JndiRepositoryFactory: declined
Perhaps the repository you are trying to access is not available at the moment.
    at org.apache.jackrabbit.commons.JcrUtils.getRepository(JcrUtils.java:223)
    at org.apache.jackrabbit.commons.JcrUtils.getRepository(JcrUtils.java:263)
    at JcrPersistance.testJcrPersistance.main(testJcrPersistance.java:17)

 

 

public class testJcrPersistance {

    public static void main(String[] args) throws ClassCastException, MalformedURLException, RemoteException, NotBoundException, LoginException, NoSuchWorkspaceException, RepositoryException, NamingException  {
        System.out.println("Hello World.");
        //RMI Connection
        Repository repository = JcrUtils.getRepository("http://localhost:4502/crx/server"); 
        //Workspace Login
        Session session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
        //List Children
        System.out.println("Workspace: " + session.getWorkspace().getName() + "\n");
        Node root = session.getRootNode(); 
        listChildren( "", root);
    }
 
    private static void listChildren(String indent, Node node ) throws RepositoryException {
        System.out.println(indent + node.getName() ); 
        NodeIterator ni = node.getNodes();
        while(ni.hasNext()) {
            listChildren(indent+"  ", ni.nextNode());
        }
    }

}

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

Make sure you are using the correct JAR file -- looks like a JAR/CQ repos issue. See the discussion here:

http://helpx.adobe.com/experience-manager/using/programmatically-accessing-cq-content-using.html

2 replies

smacdonald2008
smacdonald2008Accepted solution
Level 10
October 16, 2015

Make sure you are using the correct JAR file -- looks like a JAR/CQ repos issue. See the discussion here:

http://helpx.adobe.com/experience-manager/using/programmatically-accessing-cq-content-using.html

Level 6
October 16, 2015

Thank you, the article was sufficient to help me.