3 Replies Latest reply on Mar 24, 2011 11:08 AM by a.novarini

    Exception using the Jcr Connector to Jackrabbit


      Hi all,


      Sorry for the title, but I couldn't find a better way to describe in short what I'm doing. Here the full description:


      I'm trying to extend the JCR connector so that it could connect to a remote Jackrabbit instance using webdav protocol.


      The main idea was to extend the connector and implement the method getConnection():

      • use the library spi2dav provided by jackrabbit to get the remote repository
      • create credentials
      • pass everything to the JcrRepositoryConnection


      Things seem go quite good, I can connect to the repository, authenticate, but I get the following exception when I try to call the getRoot() method from session:



      org.modeshape.graph.session.ValidationException: Missing primary node type "rep:root" for node / in workspace "default" of "JCR test"
                at org.modeshape.jcr.SessionCache$JcrNodeOperations.materialize(SessionCache.java:2595)
                at org.modeshape.graph.session.GraphSession$Node.load(GraphSession.java:1728)
                at org.modeshape.graph.session.GraphSession$Node.getPayload(GraphSession.java:2998)
                at org.modeshape.jcr.SessionCache.findJcrRootNode(SessionCache.java:558)
                at org.modeshape.jcr.JcrSession.getRootNode(JcrSession.java:847)
                at org.modeshape.jcr.JcrSession.getRootNode(JcrSession.java:106)


      The Jackrabbit repository is a brand new one, so I'm not expecting something wrong I did on that side, but I'm not sure of what this exception is trying to say to me.


      My guess is that 'rep:root', is a node not recognized by modeshape, but I really have no clue on what to do to solve this problem.


      If someone could explain me better what this exception is about, I would have some more chance...


      Thanks in advance


        • 1. Exception using the Jcr Connector to Jackrabbit

          I think the problem you're experiencing is because the Jackrabbit repository contains node types that are not known to ModeShape. For example, the "rep" namespace is non-standard and repository-specific. I thought Jackrabbit had several of these; ModeShape uses the "mode" and "modeint" namespaces in a similar way.


          At this time, the JCR connector isn't able to expose the node types dynamically to the ModeShape JCR layer, so you have to make sure that ModeShape has all of the node types that are used in the connector's repository.


          I'd try putting all the node type definitions from these Jackrabbit-specific namespaces and any other non-standard node types within the connector's repository into one or more CND files, and then registering those node types by specifying the CND file(s) in the ModeShape configuration.

          • 2. Exception using the Jcr Connector to Jackrabbit

            Ok, this surely makes a lot of sense.


            Thanks for the advice.




            • 3. Re: Exception using the Jcr Connector to Jackrabbit

              Hello again,


              I added the cnd file with the custom nodes for jackrabbit and modeshape didn't complain anymore, so I tried to go further.


              Now I have an exception that looks very similar to the one present in the JIRA issued MODE-879, with a slight difference.

              Basically I tried to add a node to the root node and save the session, this is the exception I got:



              Exception in thread "main" org.modeshape.graph.property.PathNotFoundException: Unable to find "/{http://www.jcp.org/jcr/1.0}system[2]"; lowest existing path is "/"
                        at org.modeshape.connector.jcr.JcrRequestProcessor$Workspace.node(JcrRequestProcessor.java:893)
                        at org.modeshape.connector.jcr.JcrRequestProcessor.process(JcrRequestProcessor.java:356)
                        at org.modeshape.graph.request.processor.RequestProcessor.process(RequestProcessor.java:288)
                        at org.modeshape.graph.request.processor.RequestProcessor.process(RequestProcessor.java:354)
                        at org.modeshape.graph.request.processor.RequestProcessor.process(RequestProcessor.java:229)
                        at org.modeshape.connector.jcr.JcrRepositoryConnection.execute(JcrRepositoryConnection.java:119)
                        at org.modeshape.graph.connector.RepositoryConnectionPool$ConnectionWrapper.execute(RepositoryConnectionPool.java:1129)
                        at org.modeshape.graph.request.CompositeRequestChannel$2.call(CompositeRequestChannel.java:193)
                        at org.modeshape.graph.request.CompositeRequestChannel$2.call(CompositeRequestChannel.java:183)
                        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
                        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
                        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
                        at java.lang.Thread.run(Thread.java:680)


              This is the code I'm testing:


                      logger.info("Starting tests");
                      try {
                          JcrRepository repository = engine.getRepository("test");
                          logger.info("Got repository test");
                          Session session = repository.login();
                          logger.info("Got valid session");
                          Node rootNode = session.getRootNode();
                          logger.info("Got root node: " + rootNode);
                          Workspace workspace = session.getWorkspace();
                          logger.info("Current workspace: " + workspace.getName());
                          logger.info("Added node myNode to root node");
                          logger.info("Logged out");
                      } catch (RepositoryException e) {


              And this is the output:


              777 [main] INFO com.sourcesense.stone.extensions.it.Modeshape2JackrabbitConnectorIT - Starting tests
              1083 [main] INFO com.sourcesense.stone.extensions.RepositoryFactory - Creating repository from url: http://localhost:8080/server
              1314 [main] INFO com.sourcesense.stone.extensions.CredentialsFactory - Creating credentials with username: admin, password: admin
              1315 [main] INFO com.sourcesense.stone.extensions.RepositoryConnectionFactory - Creating a repository connection
              30340 [main] INFO com.sourcesense.stone.extensions.it.Modeshape2JackrabbitConnectorIT - Got repository test
              30503 [main] INFO com.sourcesense.stone.extensions.it.Modeshape2JackrabbitConnectorIT - Got valid session
              30557 [main] INFO com.sourcesense.stone.extensions.it.Modeshape2JackrabbitConnectorIT - Got root node: / {jcr:primaryType=rep:root, jcr:mixinTypes=[rep:AccessControllable], }
              30557 [main] INFO com.sourcesense.stone.extensions.it.Modeshape2JackrabbitConnectorIT - Current workspace: default
              Exception in thread "main" org.modeshape.graph.property.PathNotFoundException: Unable to find "/{http://www.jcp.org/jcr/1.0}system[2]"; lowest existing path is "/"


              While debugging, I reached the org.modeshape.jcr.SessionCache class, and I think I discovered something interesting:

              The content of the graphSession field is the following:


              {1=Cached node <1> at { / }, 2=Cached node <2> at { /{httpwww.jcp.orgjcr1.0}system }, 3=Cached node <3> at { /{internal}policy }, 4=Cached node <4> at { /{httpwww.jcp.orgjcr1.0}system[2] }, 5=Cached node <5> at { /{}myNode }}


              Please note the encoding of ':' and of '/'; is that the problem that cause a mismatch when searching item by key in this map?


              What do you thing?


              Thanks a lot



              Message was edited by: Alessandro Novarini, I added other - hopefully - usefull information to understand what's happening