4 Replies Latest reply on Oct 9, 2015 3:35 AM by Sylvain Perrinel

    Integrate WebDav/Rest and WebExplorer in a single Webapp

    Sylvain Perrinel Newbie

      Hello,

      I use ModeShape 4.4.0.Final and I would like to integrate Webdav/Rest and Web Explorer interfaces in a single Webapp. But web explorer doesn't use the same mecanism to get repositories than WebDav and Rest interfaces.

      • Webdav/Rest use RepositoryManager class and JcrRepositoriesContainer class to start a ModeShapeEngine and deploy Repositories.
      • Web explorer use JcrServiceImpl class and JsonConfigConnectorImpl class to start another ModeShapeEngine and deploy Repositories.

      So I have an exception from Infinispan and LevelDB because two engines uses the same configuration.

       

      Why the mecanism is different ? Maybe my configuration is wrong. Is this possible to get web explorer frontend with webdav/rest interfaces ?

      Thanks

        • 1. Re: Integrate WebDav/Rest and WebExplorer in a single Webapp
          Horia Chiorean Master

          The 3 applications are completely independent of each other, as they each offer a completely different facet of functionality.  On the other hand, you can have all 3 of them running in the same container (e.g JBossAS) against the same set of repositories. But to do this, you have to make sure each of the web applications is configured to access a/the ModeShapeEngine instance bound in JNDI in that particular server.

           

          You can have a look at the web.xml files of the web applications from the ModeShape AS kit here: modeshape/deploy/jbossas at master · ModeShape/modeshape · GitHub Each of wars packaged for JBossAS is configured to access a ModeShape engine instance bound under jndi:/jcr. If you're using another container (not JBoss AS) you can look at Using ModeShape - ModeShape 4 - Project Documentation Editor for how you can bind an engine/repository using a JNDI Object Factory.

          • 2. Re: Integrate WebDav/Rest and WebExplorer in a single Webapp
            Sylvain Perrinel Newbie

            Thank you.

            I'm working with Tomcat 7.

            I configured my WEb-INF/web.xml like this :

             

            <context-param>
              <param-name>org.modeshape.jcr.URL</param-name>
            
              <param-value>jndi:jcr</aram-value>
            </context-param>
            
            

            and my META-INF/context.xml :

            <?xml version='1.0' encoding='utf-8'?>
            <Context antiJARLocking="true">
              <Resource name="jcr/myrepo"
            
               auth="Container"
               factory="org.modeshape.jcr.JndiRepositoryFactory"
               repositoryName="myRepository"
               type="javax.jcr.Repository"
               configFile="repository-config.json" />
            </Context>
            
            
            
            

             

            But Engin won't start and exception is throwed :

            14:39:17.137 ERROR o.m.w.j.RepositoryManager - Cannot load the names of the available repositories.

            javax.jcr.RepositoryException: javax.naming.NameNotFoundException: Le Nom jcr n'est pas lié à ce Contexte

                at org.modeshape.jcr.JcrRepositoriesContainer$JNDIRepositoryLookup.doJNDILookup(JcrRepositoriesContainer.java:315) ~[modeshape-jcr-4.4.0.Final.jar:4.4.0.Final]

                at org.modeshape.jcr.JcrRepositoriesContainer$JNDIRepositoryLookup.repositoryNames(JcrRepositoriesContainer.java:341) ~[modeshape-jcr-4.4.0.Final.jar:4.4.0.Final]

                at org.modeshape.jcr.JcrRepositoriesContainer.getRepositoryNames(JcrRepositoriesContainer.java:104) ~[modeshape-jcr-4.4.0.Final.jar:4.4.0.Final]

                at org.modeshape.web.jcr.RepositoryManager.getJcrRepositoryNames(RepositoryManager.java:145) ~[modeshape-web-jcr-4.4.0.Final.jar:4.4.0.Final]

                at org.modeshape.web.jcr.rest.handler.RestServerHandler.getRepositories(RestServerHandler.java:43) [modeshape-web-jcr-rest-4.4.0.Final.jar:4.4.0.Final]

                at org.modeshape.web.jcr.rest.ModeShapeRestService.getRepositories(ModeShapeRestService.java:157) [modeshape-web-jcr-rest-4.4.0.Final.jar:4.4.0.Final]

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_45-internal]

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_45-internal]

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_45-internal]

                at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_45-internal]

                at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:137) [resteasy-jaxrs-3.0.11.Final.jar:na]

                at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:296) [resteasy-jaxrs-3.0.11.Final.jar:na]

                at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:250) [resteasy-jaxrs-3.0.11.Final.jar:na]

                at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:237) [resteasy-jaxrs-3.0.11.Final.jar:na]

                at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:356) [resteasy-jaxrs-3.0.11.Final.jar:na]

                at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179) [resteasy-jaxrs-3.0.11.Final.jar:na]

                at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220) [resteasy-jaxrs-3.0.11.Final.jar:na]

                at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56) [resteasy-jaxrs-3.0.11.Final.jar:na]

                at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51) [resteasy-jaxrs-3.0.11.Final.jar:na]

                at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) [servlet-api.jar:na]

                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) [catalina.jar:7.0.63]

                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.63]

                at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat7-websocket.jar:7.0.63]

                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [catalina.jar:7.0.63]

                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.63]

                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) [catalina.jar:7.0.63]

                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) [catalina.jar:7.0.63]

                at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) [catalina.jar:7.0.63]

                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) [catalina.jar:7.0.63]

                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) [catalina.jar:7.0.63]

                at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957) [catalina.jar:7.0.63]

                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) [catalina.jar:7.0.63]

                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423) [catalina.jar:7.0.63]

                at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079) [tomcat-coyote.jar:7.0.63]

                at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620) [tomcat-coyote.jar:7.0.63]

                at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318) [tomcat-coyote.jar:7.0.63]

                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_45-internal]

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_45-internal]

                at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-coyote.jar:7.0.63]

                at java.lang.Thread.run(Thread.java:745) [na:1.8.0_45-internal]

            Caused by: javax.naming.NameNotFoundException: Le Nom jcr n'est pas lié à ce Contexte

                at org.apache.naming.NamingContext.lookup(NamingContext.java:819) ~[catalina.jar:7.0.63]

                at org.apache.naming.NamingContext.lookup(NamingContext.java:167) ~[catalina.jar:7.0.63]

                at org.apache.naming.SelectorContext.lookup(SelectorContext.java:156) ~[catalina.jar:7.0.63]

                at javax.naming.InitialContext.lookup(InitialContext.java:417) ~[na:1.8.0_45-internal]

                at org.modeshape.jcr.JcrRepositoriesContainer$JNDIRepositoryLookup.doJNDILookup(JcrRepositoriesContainer.java:313) ~[modeshape-jcr-4.4.0.Final.jar:4.4.0.Final]

                ... 39 common frames omitted

             

             

            Any Ideas ?

            • 3. Re: Integrate WebDav/Rest and WebExplorer in a single Webapp
              Horia Chiorean Master

              The Web Explorer JNDI connector is limited to only being able to search for a general ModeShapeEngine instance in JNDI, not a specific repository (an engine can have any number of repositories). So you need to configure the Tomcat JNDI resource to be a ModeShapeEngine, not a repository. To do this, you essentially have to omit the repositoryName attribute (I've also updated our documentation on this topic: ModeShape in web applications - ModeShape 4 - Project Documentation Editor)

               

              Also, in your example make sure you use the same JNDI name for the <param-value> and <Resource name. In this particular case, it should be  <Resource name="jcr">

              • 4. Re: Integrate WebDav/Rest and WebExplorer in a single Webapp
                Sylvain Perrinel Newbie

                Thanks.

                I finally found a solution. Apache Tomcat 7 documentation on resource definitions said : https://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Resource_Definitions

                on "name" property : "The name of the resource to be created, relative to the java:comp/env context."

                 

                With Tomcat, Jndi Resource are resgistred in java:comp/env.

                 

                Here's the configuration in context.xml :

                <?xml version='1.0' encoding='utf-8'?>
                <Context antiJARLocking="true">
                  <Resource name="jcr/myrepo"
                   auth="Container"
                   factory="org.modeshape.jcr.JndiRepositoryFactory"
                   configFiles="repository-config.json" />
                </Context>
                
                

                and in web.xml :


                <!-- Configuration for enabling Dav/Rest With JNDI -->
                <context-param>
                  <param-name>org.modeshape.jcr.URL</param-name>
                  <param-value>jndi:java:comp/env/jcr/myrepo</param-value>
                </context-param>
                
                <!-- Configuration for enabling a Repository Web Explorer with JNDI : browser interface for JCR compliant repositories-->
                <context-param>
                  <param-name>jndi-prefix</param-name>
                  <param-value>java:comp/env/jcr/myrepo</param-value>
                </context-param>

                 



                Thank you