1 2 Previous Next 18 Replies Latest reply on Apr 24, 2013 6:20 AM by jaraful

    Could not load or find a ModeShape repository

    jaraful

      Hi guys,

       

      I'm testing the new implementation of ModeShape 3 with my JBoss 7.1.1 Final. I've followed the installations steps one by one.

      I start the server with the parameter -c=standalone-modeshape.xml and at the end of the server load, I get this WARN:

       

      13:52:08,587 WARN  [org.modeshape.jcr.JcrRepositoryFactory] (MSC service thread 1-1) Could not load or find a ModeShape repository named 'sample' using the URL 'jndi:jcr' and params: {org.modeshape.jcr.RepositoryName=sample, org.modeshape.jcr.URL=jndi:jcr}

      13:52:08,589 INFO  [stdout] (MSC service thread 1-1) --- loaded repository sample

       

      When I try to connect to the repository, I get allways a null. I've tried to use the three methods:

      • Injection.
      • JNDI.
      • RepositoryFactory.

       

      The repository exists because I can access the webpage: http://localhost:8080/modeshape-rest/sample. I get the correct configuration:

       

      {"workspaces": [{

        "name": "default",

        "repository": "http://localhost:8080/modeshape-rest/sample",

        "items": "http://localhost:8080/modeshape-rest/sample/default/items",

        "query": "http://localhost:8080/modeshape-rest/sample/default/query",

        "binary": "http://localhost:8080/modeshape-rest/sample/default/binary",

        "nodeTypes": "http://localhost:8080/modeshape-rest/sample/default/nodetypes"

      }]}

       

      Does this happened to anyone else?

       

      (The full server load log is attached)

        • 1. Re: Could not load or find a ModeShape repository
          hchiorean

          The WARN is benign, so just ignore it. The next line from your startup log is "11:35:19,301 INFO  [stdout] (MSC service thread 1-2) --- loaded repository sample", which means that the repository is loaded ok.

          1 of 1 people found this helpful
          • 2. Re: Could not load or find a ModeShape repository
            jaraful

            Thanks for your quick answer.

             

            Do you have any idea about why I get always a null repository?

            • 3. Re: Could not load or find a ModeShape repository
              hchiorean

              Not sure what the code which tries to retrieve the repository looks like, but we have quite a few integration tests which use injection via @Resource (and therefore JNDI) to retrieve deployed repositories.

               

              For example: https://github.com/ModeShape/modeshape/blob/master/integration/modeshape-jbossas-integration-tests/src/test/java/org/modeshape/test/integration/PreconfiguredRepositoryIntegrationTest.java

               

              The fact that you can connect to the repository via the REST service, is an indication that everything is deployed ok. I suspect you're maybe using the wrong JNDI resource name.

              • 4. Re: Could not load or find a ModeShape repository
                rhauch

                Did you use one of the techniques documented here for use with AS7 (or EAP 6 for our 'master' branch and what will be 3.2)?

                 

                Take a look at this test case to see how we're testing the kit. We check several methods, including JNDI. If you're still having trouble, please include your code (or appropriate fragments of it).

                • 5. Re: Could not load or find a ModeShape repository
                  jaraful

                  Well, I tried to do it that way. But obviously it doesn't work because maven gives me an error about the mappedName. You use "/jcr/preconfiguredRepository". When i try with "/jcr/sample", it returns me an error with the env:

                   

                  java.lang.IllegalArgumentException: Empty name segment is not allowed for env

                  • 6. Re: Could not load or find a ModeShape repository
                    jaraful

                    Here is my code:

                     

                    import javax.annotation.ManagedBean;

                    import javax.annotation.Resource;

                    import javax.jcr.LoginException;

                    import javax.jcr.RepositoryException;

                    import javax.jcr.Session;

                    import javax.jcr.Repository;

                     

                    import org.apache.log4j.Logger;

                     

                    @ManagedBean

                    public class CommonModeshapeRepository {

                     

                     

                              private static final Logger logger = Logger.getLogger(CommonModeshapeRepository.class);

                     

                     

                              @Resource(mappedName="java:/jcr/sample")

                              private Repository repository;

                     

                     

                              /**

                               * Creates a session connection to the repository

                               *

                               * @return the repository connection

                               */

                              public Session login() {

                                        try {

                                                  // Returns the session created by login in the repository

                                                  return repository.login();

                                        } catch (LoginException e) {

                                                  logger.error(e);

                                                  throw new Exception("Failed to login in the repository. " + e);

                                        } catch (RepositoryException e) {

                                                  logger.error(e);

                                                  throw new Exception("Failed to read the repository. " + e);

                                        }

                              }

                    }

                    • 7. Re: Could not load or find a ModeShape repository
                      hchiorean

                      The code looks correct. Can you please enable DEBUG logging for org.modeshape in the server and after the server has started up, look at the "Binding repository ...  to JNDI name .." messages. They should hopefully indicate what JNDI name is being used.

                       

                      Is the bean you are using packaged & deployed correctly into the container ? (e.g. does it have a beans.xml and/or any other files needed to trigger dependency injection). Also, are you able to successfully inject any other container resources (outside of ModeShape) in your bean ? (e.g. datasources)

                      1 of 1 people found this helpful
                      • 8. Re: Could not load or find a ModeShape repository
                        jaraful

                        Hi and thanks again!

                         

                        I added the debug for org.modeshape and you're right:

                         

                        15:35:03,474 DEBUG [org.modeshape.jboss.subsystem.AddRepository] (ServerService Thread Pool -- 61) Binding repository 'sample' to JNDI name 'java:/jcr/sample'

                         

                        I'll try to inject other dependency objects as soon as I can.

                         

                        Thank you very much. You helped me a lot. I'll write here the solution when I solve it.

                        • 9. Re: Could not load or find a ModeShape repository
                          jaraful

                          Well,

                          Finally i discovered there was an error with the previous project. I've just created a new one. But now i don't know how to manage an exception i get when it tries to inject the resource:

                           

                          Caused by: java.lang.IllegalArgumentException: Can not set javax.jcr.Repository field org.dyndns.blakeserver.repository.RepositoryConnection.repository to org.modeshape.jcr.JcrRepository

                           

                          I've searched in internet about it... but i found nothing .

                           

                          Sorry for bugging you again but, do you have any idea about why i'm getting this now?

                          • 10. Re: Could not load or find a ModeShape repository
                            satyakishor.m

                            Try to see from which jar/dependency in your project, "org.dyndns.blakeserver.repository.RepositoryConnection" class is picked up. If the jar file is not required, remove it from your project and try again.

                            • 11. Re: Could not load or find a ModeShape repository
                              jaraful

                              Hi guys,

                               

                              First of all, thanks for your answer Satya. I had a meeting yesterday and i couldn't reply you, sorry. I've been checking the dependencies and this is what i have in the EJB module where i make the Resource call:

                               

                              <dependencies>

                                   <!-- Project with the shared interfaces between the EJB and the clients -->

                                   <dependency>

                                        <groupId>org.common</groupId>

                                        <artifactId>sharedInterfaces</artifactId>

                                        <version>0.0.1-SNAPSHOT</version>

                                        <scope>provided</scope>

                                   </dependency>

                               

                                   <dependency>

                                        <groupId>javax.jcr</groupId>

                                        <artifactId>jcr</artifactId>

                                        <version>2.0</version>

                                   </dependency>

                               

                                   <dependency>

                                        <groupId>org.jboss.spec.javax.ejb</groupId>

                                        <artifactId>jboss-ejb-api_3.1_spec</artifactId>

                                        <scope>provided</scope>

                                   </dependency>

                              </dependencies>

                               

                              And the class is like this:

                               

                              @Stateless

                              public class RepositoryConnection implements IRepositoryConnectiion {

                                   @Resource(mappedName="java:/jcr/sample")

                                   private Repository repository;

                                   @SuppressWarnings("unused")

                                   private Session session;

                               

                                   @Override

                                   public boolean login(){

                                        try {

                                             session = repository.login();

                                             return true;

                                        } catch (LoginException e) {

                                             e.printStackTrace();

                                             return false;

                                        } catch (RepositoryException e) {

                                             e.printStackTrace();

                                             return false;

                                        }

                                   }

                              }

                               

                              It's a dummy class for testing the repository.

                              • 12. Re: Could not load or find a ModeShape repository
                                rhauch

                                One problem is with your dependencies. The "javax.jcr" artifact should be "provided", so that you're actually using the same "javax.jcr.Repository" class that the server uses. Without this, you're almost certain to get a ClassCastException (or some other ambiguous wrapper around this error).

                                 

                                I'd strongly suggest using our Maven BOM. See our documentation for details, and note that the artifactId of the BOM changed with 3.2 since we moved from AS7 to EAP 6.1. Since you're still using AS7.1.1, be sure to use the correct artifactId as documented.

                                 

                                I still think your @Resource mapping name is wrong, and should be "/jcr/sample". As Horia mentioned earlier, please see our test code for a working example.

                                • 13. Re: Could not load or find a ModeShape repository
                                  jaraful

                                  Thanks all,

                                   

                                  Finally i could make it work. Now i'm getting the same error as you mentioned here:

                                   

                                  https://community.jboss.org/thread/201241

                                   

                                  I'll follow the steps to solve it.

                                   

                                  THANKS ALL!!!

                                  • 14. Re: Could not load or find a ModeShape repository
                                    rhauch

                                    Finally i could make it work. Now i'm getting the same error as you mentioned here:

                                     

                                    https://community.jboss.org/thread/201241

                                     

                                    I'll follow the steps to solve it.

                                    Good news!

                                     

                                    I will recommend seriously considering the just-released ModeShape 3.2 on top of EAP 6.1.0 (Alpha1 or the recently-available Beta). ModeShape 3.2 is very much improved over 3.1.x, as is the underlying version of Infinispan, and the problem you're running into has been fixed. Additionally, even EAP 6.1.0.Alpha1 is a huge improvement over AS7.1.1.

                                    1 2 Previous Next