5 Replies Latest reply on Apr 2, 2014 9:53 AM by Randall Hauch

    ModeShape OSGI Container

    tao zhu Newbie

      I build a osgi project,i want to use modeshape rest and expose rest service by cxf.But when deploy the project in osgi container(servicemix ),i got a Error .



        Iterator<RepositoriesContainer> containersIterator = ServiceLoader.load(RepositoriesContainer.class).iterator();

              if (!containersIterator.hasNext()) {

                  throw new IllegalStateException(



              //there shouldn't be more than 1 container

              repositoriesContainer = containersIterator.next();

      the 'java.util.ServiceLoader' can't find RepositoriesContainer' implements.Is the modeshape(3.7.1.final) can be useed in osgi?

        • 1. Re: ModeShape OSGI Container
          Randall Hauch Master

          You would have to implement all of the OSGi functionality in a wrapper. ModeShape is not OSGi-enabled, and at this point Infinispan is not either. The Infinispan folks are working on it now, and we've had it on our roadmap for a while but really can only do it once Infinispan does.

          1 of 1 people found this helpful
          • 2. Re: ModeShape OSGI Container
            tao zhu Newbie

            hi Randall,

               thanks for your reply.I'm learning both osgi and modeshape recently.Not really know how to solve the error and what should be done.can you give me some advice?

            • 3. Re: ModeShape OSGI Container
              Randall Hauch Master

              I'm not terribly familiar with the details, but I know enough to say that the biggest challenge with using ModeShape and Infinispan in OSGi is related to class loading. So my understanding is that you can create your own custom OSGi artifact that wraps and includes all ModeShape and Infinispan libraries (and perhaps all of their dependencies). There are other options, but that's the most straightforward since it puts all ModeShape and Infinispan code into a single OSGi classloader.


              Does someone else have a better suggestion?

              • 4. Re: ModeShape OSGI Container
                tao zhu Newbie

                I have put  ModeShape and Infinispan code into a single OSGi classloader.Modeshape engine can run ,but i have got a error below when I send a get reqeust:

                javax.naming.NotContextException: The intermediate context Persisted-Repository does not exist

                  at org.apache.xbean.naming.context.AbstractContext.lookupFinalContext(AbstractContext.java:198)

                  at org.apache.xbean.naming.context.AbstractContext.addDeepBinding(AbstractContext.java:241)

                  at org.apache.xbean.naming.context.AbstractContext.bind(AbstractContext.java:660)

                  at org.apache.xbean.naming.context.AbstractContext.bind(AbstractContext.java:651)

                  at org.apache.servicemix.naming.InitialContextWrapper.bind(InitialContextWrapper.java:85)

                  at javax.naming.InitialContext.bind(InitialContext.java:400)[:1.6.0_43]

                  at org.modeshape.jcr.JcrRepository$RunningState.bindIntoJndi(JcrRepository.java:1680)[250:modeshape.rest:0.0.1.SNAPSHOT]

                  at org.modeshape.jcr.JcrRepository$RunningState.<init>(JcrRepository.java:1210)[250:modeshape.rest:0.0.1.SNAPSHOT]

                  at org.modeshape.jcr.JcrRepository$RunningState.<init>(JcrRepository.java:971)[250:modeshape.rest:0.0.1.SNAPSHOT]

                • 5. Re: ModeShape OSGI Container
                  Randall Hauch Master

                  Are you using JNDI in your application? If not, be sure to set the "jndiName" to a blank string in the repository configuration. If you are, be sure to set it to a valid JNDI name for your environment.