4 Replies Latest reply on Apr 26, 2015 1:20 PM by shane_k

    Modeshape Web Explorer [4.2.0.Final] - missing gwt-servlet dependency and no longer able to connect to repository deployed in same Tomcat 7 container

    shane_k

      Folks,

       

      A few months ago I raised a question [ Issues running modeshape-web-explorer [4.1.0.Final] on Tomcat 7 ] relating to issues running Modeshape Web Explorer in Tomcat 7. After some discussion, I was successfully able to embed Modeshape Web Explorer into my Spring MVC application and access the console as expected. I have now updated my project dependencies to use 4.2.0.Final and have encountered two issues:

       

      (a) gwt-servlet (2.5.1) is no longer a transitive dependency of the modeshape-web-explorer artifact (it was in 4.1.0.Final, but appears to be missing/removed from 4.2.0.Final) - is this intentional - should I be using a later version? I had to manually add it as a dependency to my project, otherwise I would see the following CNF exception:

       

      java.lang.ClassNotFoundException: com.google.gwt.user.client.rpc.RemoteService

      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)

      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)

      java.lang.ClassLoader.defineClass1(Native Method)

      java.lang.ClassLoader.defineClass(ClassLoader.java:760)

      java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)

      org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2957)

      org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1210)

      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1690)

      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)

      java.lang.ClassLoader.defineClass1(Native Method)

      java.lang.ClassLoader.defineClass(ClassLoader.java:760)

      java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)

      org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2957)

      org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1210)

      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1690)

      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)

      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:492)

      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)

      org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)

      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)

      org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)

      org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)

      org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)

      java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

      java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

      org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

      java.lang.Thread.run(Thread.java:745)

       

      (b) once I added the gwt-servlet (2.5.1) dependency to my project, I could now access the Console however I am presented with a modal dialog box stating: "The url argument may not be null"

       

      Nothing else has changed in the project except the switch to the new 4.2.0.Final libraries (and inclusion of gwt-servlet as a standalone dependency). Apologies if I've missed something obvious...

       

      Regards,

       

      Shane

        • 1. Re: Modeshape Web Explorer [4.2.0.Final] - missing gwt-servlet dependency and no longer able to connect to repository deployed in same Tomcat 7 container
          hchiorean

          The gwt-servlet should be listed as a runtime dependency of the web-explorer artifact. I've opened [MODE-2460] The web-explorer jar artifact should list gwt-servlet as a dependency - JBoss Issue Tracker which we'll look to fix for 4.3.

          In general however, you shouldn't be using this artifact directly but rather the modeshape-web-explorer-war artifact which has all the correct dependencies listed. This is the artifact which you should be overlaying with your custom web.xml (and other custom dependencies if it applies).

          The reason for the other error could be that you didn't configure the Web Explorer to be able to access your repository(ies). The default connector with which the Explorer jar is configured is the connector which expects a ModeShape engine instance bound in JNDI under the "jcr" prefix. If this does not apply to your case, you should use the appropriate connector instance & configuration and provide that in your web.xml file (see https://docs.jboss.org/author/display/MODE40/Repository+Web+Explorer.)

          • 2. Re: Modeshape Web Explorer [4.2.0.Final] - missing gwt-servlet dependency and no longer able to connect to repository deployed in same Tomcat 7 container
            shane_k

            Horia,

             

            Thanks for your response.

             

            With respect to using the modeshape-web-explorer-war artifact in preference to the modeshape-web-explorer artifact - thats fine - I'd chosen the non-WAR version because I was already importing modeshape-jcr explicitly (rather than rely on modeshape-web-explorer-war to pull it in for me - just in case I ever remove modeshape-web-explorer-war in future). However, regardless of whether I use the 'war' or non-war Web Explorer artifact, the end result is the same - when I use 4.1.0.Final, Modeshape Web Explorer correctly picks up the repository config from my web.xml (see below) - and I can access my repository via the web interface. But when I simply change the project dependencies to use 4.2.0.Final instead, then I get the error message I previously described (all other configuration remains the same). I don't use JNDI because Tomcat's JNDI tree is read-only and can't be modified at runtime. The problem only seems to affect the Web Explorer - I have another piece of my own code which accesses the modeshape repository via the JCR API manually and retrieve the root node, add additional notes etc in both 4.1.0.Final and 4.2.0.Final - so the issue seems specific to Web Explorer.


            Also - is there any way to easily change/override the context root of the modeshape-web-explorer web application so that it doesn't end up taking precedence over the webapp that its embedded with. For example, lets assume I have defined a context-root of 'MyWebApp' for my app (and then I've embedded modeshape-web-explorer[-war]) - when I go to http://localhost/MyWebApp in my browser I end up seeing the Modeshape Web Explorer interface (essentially the same as what you would see if you navigate directly to Console.html) instead of the default/entry page of my web application - have I missed something obvious here?

             

            web.xml

            ...
            ...
            
              <!-- Modeshape JCR Repository Context Configuration -->
              <context-param>
                <param-name>connector-class</param-name>
                <param-value>org.modeshape.web.server.impl.JsonConfigConnectorImpl</param-value>
              </context-param>
            
            
              <context-param>
                <param-name>config-url</param-name>
                <param-value>WEB-INF/classes/configuration/modeshape/repository-config.json</param-value>
              </context-param>
            
            ...
            ...
            
            
            

             

            repository-config.json

            {
              "name": "MyJCRRepo",
              "jndiName": "",
              "monitoring": {
                              "enabled": false
                            },
              "storage": {
                           "cacheName": "MyJCRRepo",
                           "cacheConfiguration": "configuration/modeshape/infinispan-config.xml",
                           "binaryStorage": {
                                              "type": "file",
                                              "directory": "${java.io.tmpdir}/jcr/MyRepo/binaries",
                                              "minimumBinarySizeInBytes": 40
                                            }
                         },
              "workspaces": {
                              "default": "default",
                              "allowCreation": true
                            },
              "security": {
                            "anonymous": {
                                           "roles": ["readonly", "readwrite", "admin"],
                                           "useOnFailedLogin": false
                                         }
                          }
            }
            
            

             

            infinispan-config.xml

            <?xml version="1.0" encoding="UTF-8"?>
            <infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                        xsi:schemaLocation="urn:infinispan:config:6.0 http://www.infinispan.org/schemas/infinispan-config-6.0.xsd"
                        xmlns="urn:infinispan:config:6.0">
            
            
              <global>
                <globalJmxStatistics
                  enabled="false"
                  allowDuplicateDomains="true"
                />
              </global>
            
            
              <namedCache name="MyJCRRepo">
                <transaction
                  transactionManagerLookupClass="org.infinispan.transaction.lookup.DummyTransactionManagerLookup"
                  transactionMode="TRANSACTIONAL"
                  lockingMode="OPTIMISTIC"
                />
            
            
                <persistence passivation="false">
                  <singleFile>
                    <properties>
                      <property name="shared" value="false" />
                      <property name="preload" value="false" />
                      <property name="fetchPersistentState" value="false" />
                      <property name="purgeOnStartup" value="false" />
                      <property name="location" value="${java.io.tmpdir}/jcr/MyJCRRepo/store" />
                    </properties>
                  </singleFile>
                </persistence>
              </namedCache>
            
            
            </infinispan>
            
            
            • 3. Re: Modeshape Web Explorer [4.2.0.Final] - missing gwt-servlet dependency and no longer able to connect to repository deployed in same Tomcat 7 container
              hchiorean

              I was mentioning using the web-explorer:war artifact because until we fix the JIRA issue I mentioned above, it's the only artifact which has the correct(complete) list of required dependencies for the standalone Web Explorer webapp.

              Also - is there any way to easily change/override the context root of the modeshape-web-explorer web application so that it doesn't end up taking precedence over the webapp that its embedded with.

              If you're using Maven for example and your own WAR module has a dependency to another WAR artifact but it also has a src/main/webapp/WEB-INF/web.xml file, this file will be by default the final web application descriptor for your application. The web-explorer:jar is a web-fragment and its descriptor looks like this: modeshape/web-fragment.xml at master · ModeShape/modeshape · GitHub. However, any context-param / welcome-file-list etc entries that you've defined in your custom web.xml should have precedence over whatever the web-fragment brings in.


              The connector configuration that you should add to your web.xml file looks like this:

               

                 <context-param>
                      <param-name>connector-class</param-name>
                      <param-value>org.modeshape.web.server.impl.JsonConfigConnectorImpl</param-value>
                  </context-param>
              
                  <context-param>
                      <param-name>config-url</param-name>
                      <param-value>configuration/modeshape/repository-config.json</param-value>
                  </context-param>
              

               

              You shouldn't add the WEB-INF/classes part to the URL because it is resolved from the classpath.

              • 4. Re: Modeshape Web Explorer [4.2.0.Final] - missing gwt-servlet dependency and no longer able to connect to repository deployed in same Tomcat 7 container
                shane_k

                Horia,

                 

                Apologies for my delay in responding. See my responses below.

                Horia Chiorean wrote:

                 

                I was mentioning using the web-explorer:war artifact because until we fix the JIRA issue I mentioned above, it's the only artifact which has the correct(complete) list of required dependencies for the standalone Web Explorer webapp.

                 

                Understood.

                 

                Horia Chiorean wrote:


                If you're using Maven for example and your own WAR module has a dependency to another WAR artifact but it also has a src/main/webapp/WEB-INF/web.xml file, this file will be by default the final web application descriptor for your application. The web-explorer:jar is a web-fragment and its descriptor looks like this: modeshape/web-fragment.xml at master · ModeShape/modeshape · GitHub. However, any context-param / welcome-file-list etc entries that you've defined in your custom web.xml should have precedence over whatever the web-fragment brings in.

                 

                Yeah - I had effectively disabled 'welcome' page functionality in my deployment descriptor and it is this which seemed to be causing this behaviour. I went back and modified the configuration to use index.html as my welcome page and my web-app now displays by default again (and I can view Modeshape Web Explorer by visiting /Console.html as before)

                 

                Horia Chiorean wrote:

                 

                The connector configuration that you should add to your web.xml file looks like this:

                 

                1.    <context-param> 
                2.         <param-name>connector-class</param-name> 
                3.         <param-value>org.modeshape.web.server.impl.JsonConfigConnectorImpl</param-value> 
                4.     </context-param> 
                5.  
                6.     <context-param> 
                7.         <param-name>config-url</param-name> 
                8.         <param-value>configuration/modeshape/repository-config.json</param-value> 
                9.     </context-param> 

                 

                You shouldn't add the WEB-INF/classes part to the URL because it is resolved from the classpath.

                 

                Done.

                 

                Everything now works as expected - in both 4.1.0.Final *and* 4.2.0.Final. Thanks once again for your assistance!

                 

                Regards,

                 

                Shane