14 Replies Latest reply: Jan 3, 2012 10:01 AM by Randall Hauch RSS

    Deploying modeshape on AS7

    Sverker Abrahamsson Novice

      Hi

      I'm trying to deploy modeshape on JBoss AS 7 but have run into problems as I can't figure out how to configure the dependencies. In deployments I have the following modules:

       

      modeshape-servies.jar

      modeshape-rest.war

      modeshape-webdav.war

       

      I've also created the org.modeshape.jcr module under the modules structure.

       

      In modeshape-services.jar/META-INF I've placed the following jboss-deployment-structure.xml:

       

      <?xml version="1.0"?>

      <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">

      <deployment>

        <resources>

         <resource-root path="modeshape-common-2.6.0.Beta2.jar"/>

        </resources>

        <dependencies>

         <module name="org.modeshape.jcr" />

        </dependencies>

      </deployment>

      </jboss-deployment-structure>

       

      In modeshape-rest.war and modeshape-webdav.war I've created WEB-INF/jboss-deployment-structure.xml like this:

       

      <?xml version="1.0"?>

      <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">

      <deployment>

        <dependencies>

         <module name="org.modeshape.jcr" />

         <module name="deployment.modeshape-services.jar" />

         <module name="org.slf4j" />

        </dependencies>

      </deployment>

      </jboss-deployment-structure>

       

      Still when deploying I get java.lang.NoClassDefFoundError: org/modeshape/common/util/CheckArg which is a class located in modeshape-service.jar/modeshape-common-2.6.0.Beta2.jar. My impression was from reading the developer guid that the jboss-deployment-structure.xml files above would add this file to the class path of the .war deployments but it's not working.

       

      Can anybody please spread some light on how to correctly configure the dependencies between the deployments above?

       

      Best regards

      Sverker

        • 1. Re: Deploying modeshape on AS7
          Randall Hauch Master

          There basically are a number of separate components:

           

          • Global Classpath - these are needed by the war files, and should include the two API classes needed by ModeShape clients: modeshape-jcr-api-<version>.jar and jcr.jar file. The "modeshape-jdbc-local-<version>.jar" file contains the ModeShape JDBC driver and is needed if and only if your web applications want to query the repository using JCR-SQL2 via the JDBC API. (I'd recommend getting it working without the JDBC driver at first; you can always add it in later once everything else is working.)
          • Services - this is everything needed by the ModeShape JCR engine (e.g., 'modeshape-jcr-<version>.jar'), including all extensions (e.g., sequencers, connectors, text extractors) and all libraries they are dependent upon. If you're not sure of the dependencies, look at our current Maven assembly that puts together the JARs that are needed for running ModeShape as a service in AS 5 and 6. Note that this includes all extension libraries and their 3rd party dependencies, so if you want to trim down you'll need to look at the dependencies needed for each extension. BTW, I don't tink this includes the SLF4J API jar because it is (or should be) available globally (I hope I'm right about this).
          • Web apps - these should be deployable and self-contained (e.g., they would have their own copies of classes like 'CheckArg'), except for the two API jars that are globally available. They are deployed just like any other web app resource.

           

          Where this gets complicated is that I don't think any of the Java classes in the "modeshape-jbossas-service" project are needed nor can be used in AS 7, since they depend on the profile service used in AS 5 and 6. I was thinking we'd need to create another Java class similar to ManagedEngine that would be instantiated by AS 7 as the service. Perhaps I'm wrong, and the Managed* classes for AS5/6 can actually work in AS7.

           

          Hopefully this is what you need to keep going. I wish I could provide more guidance on AS7 integration, but I just haven't yet had the time to dive into that.

          • 2. Re: Deploying modeshape on AS7
            Sverker Abrahamsson Novice

            Hi Randall,

            the class loading is fundamentally different in AS7 than in AS5 and AS6. I created a module under $JBOSS_HOME/modules/org/modeshape/jcr/main where I've put jcr-2.0.jar, modeshape-jcr-api-<version>.jar and modeshape-jdbc-local-<version>.jar. The modules.xml file looks like this:

             

            <?xml version="1.0"?>
            <module xmlns="urn:jboss:module:1.0" name="org.modeshape.jcr">
            <resources>
              <resource-root path="jcr-2.0.jar" />
              <resource-root path="modeshape-jcr-api-2.6.0.Beta2.jar" />
              <resource-root path="modeshape-jdbc-local-2.6.0.Beta2.jar" />
            </resources>
            </module>

             

            This module is refered to by the jboss-deployment-structure.xml files mentioned above, so far it seams to work. It is neccesary to declare the dependency on org.slf4j as otherwise that module will not be availible on the class path for the .war modules.

             

            My specific question in this thread was why it doesn't work with the dependencies as I declare them above to make modeshape-common-<version>.jar from modeshape-services.jar deployment availible to the two .war deployments. If I copy modeshape-common-<version>.jar to WEB-INF/lib on the .war deployments then I don't get that NoClassDefFoundError.

            • 3. Re: Deploying modeshape on AS7
              Randall Hauch Master

              My specific question in this thread was why it doesn't work with the dependencies as I declare them above to make modeshape-common-<version>.jar from modeshape-services.jar deployment availible to the two .war deployments. If I copy modeshape-common-<version>.jar to WEB-INF/lib on the .war deployments then I don't get that NoClassDefFoundError.

               

              Frankly I'm not sure why the WAR files don't contain the 'modeshape-common-<version>.jar' file in their WEB-INF/lib directory. The code is definitely dependent upon classes in that JAR. What if you add that JAR to the WAR file? Perhaps that's a packaging issue that doesn't really manifest itself in AS 5 or 6.

              • 4. Re: Deploying modeshape on AS7
                Sverker Abrahamsson Novice

                I believe that on AS 5/6 if the modeshape-common-<version>.jar file would be placed in the .war deployments then that would cause ClassCastExceptions when they access the service as they get different class loaders. On AS 5/6 you really need to take care that any class is only present once on deployments that needs to interact, also known as the class loading hell...

                 

                As the behaviour of AS 7 is completly different the jboss-deployment-structure.xml file is used to declare what dependencies a module has unless the container detects it and add the dependency automatically. That was the purpose of my question in this thread, to figure out how to properly declare these dependencies between the deployments. As I read the developers guide the above jboss-deployment-structure.xml files would do the trick but I still get the NoClassDefFoundError.

                 

                May I suggest that we move over the Modeshape-specific discussion to the other thread I started some time ago in the Modeshape forum and keep this thread on the question on how to configure AS 7 class loading and modules? There I'll also answer to you what happens when I put the common jar in the .war files lib . There are most likely also other aspects to consider on how to make Modeshape work best under AS 7 that we need to discuss.

                 

                /Sverker

                • 5. Re: Deploying modeshape on AS7
                  Sverker Abrahamsson Novice

                  Update. If I put modeshape-common-<version>.jar in modules/org/modeshape/jcr/main and add it to the module.xml then it is provided to the .war deployments, but not if I try to export it from the .jar deployment.

                  • 6. Re: Deploying modeshape on AS7
                    Sverker Abrahamsson Novice

                    I found out from this thread: http://community.jboss.org/thread/171692 that I need to use the nightly snapshot as pojo deployment is not availible in AS 7.0.1.Final but will be in 7.0.2.Final. With the nightly jboss finds the META-INF/jboss-beans.xml file and tries to deploys it.

                     

                    However, I then get NoClassDefFoundError on classes which are present as .jar files within the jar deployment. It seems that entries in jboss-deployment-structure.xml under deployment-structure/deployment/resources are not added to the class path.

                     

                    Next try was to add a module in META-INF/jboss-deployment-structure.xml in the exploded jar deployment, but that failed on indexing the jar's.

                     

                    I then moved all the jar files from deployment/modeshape-services.jar/ to modules/org/modshape/services/main and created a module.xml there listing all the files as resources. That made those classes availible on the class path.

                     

                    Next issue that I ran in to was that org.jboss.as.pojo module could not find the classes in module org.modeshape.services, even though deployment/modeshape-services.jar/META-INF/jboss-deployment-structure.xml declared the dependency. I had to add org.modeshape.services in the module.xml file of org.jboss.as.pojo.

                     

                    So, to summarize I believe there are two issues here (which might actually be the same issue):

                     

                    1. Why are not the jar files in modshape-services.jar deployment made availible on the class path even when declared in resources section? They are neither availible to the deployed module itself nor other deployments that depends on it.

                     

                    2. Why in this scenatio would org.jboss.as.pojo need a dependency to be declared on org.modeshape.services when deployment.modeshape-services.jar, which contails the META-INF/jboss-bean.xml file declare that dependency?

                    • 7. Re: Deploying modeshape on AS7
                      Ales Justin Master

                      2. Why in this scenatio would org.jboss.as.pojo need a dependency to be declared on org.modeshape.services when deployment.modeshape-services.jar, which contails the META-INF/jboss-bean.xml file declare that dependency?

                      Can you provide the full stack trace of this?

                       

                      Since you're definitely right, POJO module shouldn't need the dependency on any other module.

                      • 8. Re: Deploying modeshape on AS7
                        Sverker Abrahamsson Novice

                        Certainly, here comes the stacktrace:

                         

                        15:50:02,089 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) Starting deployment of "modeshape-services.jar"
                        15:50:02,232 INFO  [org.jboss.as.jpa] (MSC service thread 1-1) added javax.persistence.api dependency to modeshape-services.jar
                        15:50:03,407 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.pojo.ModeShapeEngin
                        e.CONFIGURED: org.jboss.msc.service.StartException in service jboss.pojo.ModeShapeEngine.CONFIGURED: java.lang.reflect.InvocationTar
                        getException
                                at org.jboss.as.pojo.service.ConfiguredPojoPhase.configure(ConfiguredPojoPhase.java:70)
                                at org.jboss.as.pojo.service.ConfiguredPojoPhase.start(ConfiguredPojoPhase.java:97)
                                at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.j
                        ar:1.0.1.GA]
                                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.
                        GA]
                                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_24]
                                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_24]
                                at java.lang.Thread.run(Thread.java:662) [:1.6.0_24]
                        Caused by: java.lang.reflect.InvocationTargetException
                                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_24]
                                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_24]
                                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_24]
                                at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_24]
                                at org.jboss.as.pojo.service.MethodJoinpoint.dispatch(MethodJoinpoint.java:41)
                                at org.jboss.as.pojo.service.ConfiguredPojoPhase.configure(ConfiguredPojoPhase.java:91)
                                at org.jboss.as.pojo.service.ConfiguredPojoPhase.configure(ConfiguredPojoPhase.java:60)
                                ... 6 more
                        Caused by: java.lang.ExceptionInInitializerError
                                at org.modeshape.repository.ModeShapeConfiguration.<init>(ModeShapeConfiguration.java:115)
                                at org.modeshape.jcr.JcrConfiguration.<init>(JcrConfiguration.java:296)
                                at org.modeshape.jboss.managed.ManagedEngine.loadConfigurationAndCreateEngine(ManagedEngine.java:105)
                                at org.modeshape.jboss.managed.ManagedEngine.setConfigURL(ManagedEngine.java:100)
                                ... 13 more
                        Caused by: org.modeshape.common.SystemFailureException: java.lang.ClassNotFoundException: org.modeshape.graph.mimetype.ExtensionBase
                        dMimeTypeDetector from [Module "org.jboss.as.pojo:main" from local module loader @470b9279 (roots: D:\java\jboss-as-7.1.0.Alpha1-SNA
                        PSHOT\modules)]
                                at org.modeshape.common.component.ComponentLibrary.newInstance(ComponentLibrary.java:318)
                                at org.modeshape.common.component.ComponentLibrary.add(ComponentLibrary.java:162)
                                at org.modeshape.graph.mimetype.MimeTypeDetectors.addDetector(MimeTypeDetectors.java:67)
                                at org.modeshape.graph.ExecutionContext.createDefaultMimeTypeDetector(ExecutionContext.java:177)
                                at org.modeshape.graph.ExecutionContext.<init>(ExecutionContext.java:169)
                                at org.modeshape.graph.ExecutionContext.<init>(ExecutionContext.java:87)
                                at org.modeshape.graph.ExecutionContext.<clinit>(ExecutionContext.java:66)
                                ... 17 more
                        Caused by: java.lang.ClassNotFoundException: org.modeshape.graph.mimetype.ExtensionBasedMimeTypeDetector from [Module "org.jboss.as.
                        pojo:main" from local module loader @470b9279 (roots: D:\java\jboss-as-7.1.0.Alpha1-SNAPSHOT\modules)]
                                at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191)
                                at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:361)
                                at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:333)
                                at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:310)
                                at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:103)
                                at java.lang.Class.forName0(Native Method) [:1.6.0_24]
                                at java.lang.Class.forName(Class.java:247) [:1.6.0_24]
                                at org.modeshape.common.component.ComponentLibrary.newInstance(ComponentLibrary.java:303)
                                ... 23 more

                        15:50:03,643 INFO  [org.jboss.as.server.controller] (DeploymentScanner-threads - 2) Deployment of "modeshape-services.jar" was rolle
                        d back with failure message {"Failed services" => {"jboss.pojo.ModeShapeEngine.CONFIGURED" => "org.jboss.msc.service.StartException
                        in service jboss.pojo.ModeShapeEngine.CONFIGURED: java.lang.reflect.InvocationTargetException"},"Services with missing/unavailable d
                        ependencies" => ["jboss.pojo.ModeShapeSequencingService.CONFIGURED missing [ jboss.pojo.ModeShapeEngine.INSTALLED ]","jboss.pojo.JND
                        IManaged.CONFIGURED missing [ jboss.pojo.ModeShapeEngine.INSTALLED ]"]}
                        15:50:03,660 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) Stopped deployment modeshape-services.jar in 17ms
                        15:50:03,663 ERROR [org.jboss.as.deployment] (DeploymentScanner-threads - 1) {"Composite operation failed and was rolled back. Steps
                        that failed:" => {"Operation step-2" => {"Failed services" => {"jboss.pojo.ModeShapeEngine.CONFIGURED" => "org.jboss.msc.service.St
                        artException in service jboss.pojo.ModeShapeEngine.CONFIGURED: java.lang.reflect.InvocationTargetException"},"Services with missing/
                        unavailable dependencies" => ["jboss.pojo.ModeShapeSequencingService.CONFIGURED missing [ jboss.pojo.ModeShapeEngine.INSTALLED ]","j
                        boss.pojo.JNDIManaged.CONFIGURED missing [ jboss.pojo.ModeShapeEngine.INSTALLED ]"]}}}

                        • 9. Re: Deploying modeshape on AS7
                          Ted Jones Expert

                          Hi Sverker,

                           

                          Do you have any code you would like to contribute to assist with AS 7 integration?

                           

                          Thanks,

                          Ted

                          • 10. Re: Deploying modeshape on AS7
                            Sverker Abrahamsson Novice

                            Hi Ted,

                            not yet but I would like to assist. I'd need some pointer though on where to start searching.

                             

                            I believe the first step would be to solve the issue that with a (exploded) jar deployment the jar files it contain is not added to the class path despite what is specified in jboss-deployment-structure.xml. I've tried to run the deployment in debugger but didn't find the right part yet where it is supposed to happen.

                            /Sverker

                            • 11. Re: Deploying modeshape on AS7
                              Randall Hauch Master

                              not yet but I would like to assist. I'd need some pointer though on where to start searching.

                               

                              We'd definitely appreciate any help. While we can accept trivial contributions, anything else requires signing a contributor agreement for the ModeShape project. If you're interested, we'd love to have you contribute.

                               

                              There's some newer documentation for extending AS7, and that appears to document what we'll need to create a ModeShape service for AS7, which would basically be similar to our existing service for AS5 and 6.

                              • 12. Re: Deploying modeshape on AS7
                                Sverker Abrahamsson Novice

                                Yes, I know the process with the contributor agreement and I don't have any problem with that. It will be needed for the S3 connector anyway.

                                • 13. Re: Deploying modeshape on AS7
                                  Claudiu Muresan Newbie

                                  Is there an update to this problem? Did someone succeded integrating Modeshape with AS 7?

                                  • 14. Re: Deploying modeshape on AS7
                                    Randall Hauch Master

                                    Nothing has been done with ModeShape 2.x and AS7 in the official codebase. Since AS7 integration is signficantly different than AS5 or AS6, we're focusing our AS7 integration work to be done in the 3.x codebase. Our goals is to have that working with AS7 by the end of the month, but we hope to have something working in either the first or second 3.0 alpha release (mid-Jan).

                                     

                                    A workaround is to deploy ModeShape not as a service in AS7 but as a component of your application or a sibling web app. This is similar to how ModeShape is deployed in other application servers or servlet containers (such as Tomcat or Glassfish).

                                     

                                    Has anyone in the community tried deploying ModeShape as a service into AS7?