5 Replies Latest reply on Mar 20, 2013 3:09 AM by Ketki17

    Fail to access CRX with JcrUtils.getRepository

    u005078 Level 1

      I just started with CQ5/CRX/JCR, so I beg your pardon if asking silly questions.

      I'm running a CQ5 Standalone Server (CQ_5_5_Quickstart.jar) on my Windows 7 and am fine with accessing it with my browser and the URL "http://localhost:4502".

      Now I try to access it via a Java-client using the JcrUtils.getRepository-method, as described in http://dev.day.com/docs/en/crx/current/developing/accessing_the_crx.html.

      But this fails with message:

      javax.jcr.RepositoryException: Unable to access a repository with the following settings:

          org.apache.jackrabbit.repository.uri: http://localhost:4502/crx/server

      The following RepositoryFactory classes were consulted:

          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:199)

      at org.apache.jackrabbit.commons.JcrUtils.getRepository(JcrUtils.java:239)

      at AccessJCR.connectJcrUtils2(AccessJCR.java:32)

      at AccessJCR.main(AccessJCR.java:16)

       

      I'm not sure about the used URL; I just took it from cited webpage. There is said: "The default server's endpoint URL is http://host:port/crx/server. Make sure you adapt the client-side connection URL in case of customized server installation.".

      I didn't customize anything so this should be ok. I will attach the complete Code, hopefully you can give some hints.

       

      Regards,

      Ulrich

       

      [code]

      import java.util.*;

      import javax.jcr.*;

      public class AccessJCR {

            public AccessJCR() {}

       

            public static void main(String[] args) {

                 AccessJCR ajcr = new AccessJCR();

                 try {

                      ajcr.connect();

                 }

                 catch (Exception ce) {

                      ce.printStackTrace();

                  }

              }

       

            private void connect() throws Exception {

                 //Create a connection to the Day CQ repository running on local host

                 Repository repository = org.apache.jackrabbit.commons.JcrUtils.getRepository("http://localhost:4502/crx/server");

              }

      }

      [/code]