Expand my Community achievements bar.

SOLVED

Error on connecting to JCR using JcrUtils.getRepositor

Avatar

Level 6

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

}

1 Accepted Solution

Avatar

Correct answer by
Level 10

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

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

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

Avatar

Level 6

Thank you, the article was sufficient to help me.