9 Replies Latest reply on Mar 13, 2013 12:18 PM by suikast42

    7.2.0.Final and jboss-deployment-structure.xml

    suikast42

      Hi Guys,

       

      I try to migrate my ear app from 7.1.1.Final to 7.2.0.Final. during the deployment the drools classes are not found. This works fine 7.1.1.Final.

       

      I create a modules directory for drools libs. And refer to it from jboss-deployment-structure.xml.

       

      <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
      <!--
      <ear-subdeployments-isolated>true</ear-subdeployments-isolated>
       -->
          <deployment>
          
              <dependencies>
                  <module name="org.drools" slot="main"  />
                  <module name="org.hibernate" slot="main"   />
                  <!-- 
                   -->
                  <module name="org.infinispan" slot="main" />
                  <module name="org.jboss.as.clustering.infinispan"/>
              </dependencies>
          </deployment>
      </jboss-deployment-structure>
      

       

      I get allways a ClassNotDoundExcpetion Caused by: java.lang.ClassNotFoundException: org.drools.SystemEventListener

       

      If I register my drools module as global module then everrything works fine.

       

       

       <global-modules>
                  <module name="org.drools"/>
        </global-modules>
      

       

       

      But with this approch I have problems to configure log4j. Is  jboss-deployment-structure.xml invalid for 7.2.0.Final ??

        • 1. Re: 7.2.0.Final and jboss-deployment-structure.xml
          jaysensharma

          Hi,

           

             I tested  My Demo Drools application as with the following kind of "jboss-deployment-structure.xml"  and it is working fine at my end on "AS 7.2.0.Alpha1"

           

          "WEB-INF/jboss-deployment-structure.xml"

          =========================

          <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
              <deployment>  
                  <dependencies>
                      <module name="org.drools"/>
                  </dependencies>
              </deployment>
          </jboss-deployment-structure>
          

           

           

          module.xml

          ========================

          <?xml version="1.0" ?>
          <module xmlns="urn:jboss:module:1.1" name="org.drools" slot="main">
              <resources>
                  <resource-root path="xstream-1.4.1.jar"/>
                  <resource-root path="xpp3_min-1.1.4c.jar"/>
                  <resource-root path="xmlpull-1.1.3.1.jar"/>
                  <resource-root path="xml-apis-1.3.04.jar"/>
                  <resource-root path="stringtemplate-3.2.1.jar"/>
                  <resource-root path="slf4j-api-1.6.0.jar"/>
                  <resource-root path="persistence-api-1.0.jar"/>
                  <resource-root path="mvel2-2.1.0.drools4.jar"/>
                  <resource-root path="log4j-1.2.14.jar"/>
                  <resource-root path="knowledge-api-5.3.0.Final.jar"/>
                  <resource-root path="jxl-2.6.10.jar"/>
                  <resource-root path="jta-1.1.jar"/>
                  <resource-root path="jsr94-1.1.jar"/>
                  <resource-root path="javassist-3.12.0.GA.jar"/>
                  <resource-root path="itext-2.1.2.jar"/>
                  <resource-root path="hibernate-entitymanager-3.4.0.GA.jar"/>
                  <resource-root path="hibernate-core-3.3.2.GA.jar"/>
                  <resource-root path="hibernate-commons-annotations-3.1.0.GA.jar"/>
                  <resource-root path="hibernate-annotations-3.4.0.GA.jar"/>
                  <resource-root path="google-collections-1.0.jar"/>
                  <resource-root path="ejb3-persistence-1.0.2.GA.jar"/>
                  <resource-root path="ecj-3.5.1.jar"/>
                  <resource-root path="drools-verifier-5.3.0.Final.jar"/>
                  <resource-root path="drools-templates-5.3.0.Final.jar"/>
                  <resource-root path="drools-persistence-jpa-5.3.0.Final.jar"/>
                  <resource-root path="drools-jsr94-5.3.0.Final.jar"/>
                  <resource-root path="drools-decisiontables-5.3.0.Final.jar"/>
                  <resource-root path="drools-core-5.3.0.Final.jar"/>
                  <resource-root path="drools-compiler-5.3.0.Final.jar"/>
                  <resource-root path="drools-clips-5.3.0.Final.jar"/>
                  <resource-root path="dom4j-1.6.1.jar"/>
                  <resource-root path="commons-collections-3.1.jar"/>
                  <resource-root path="bcprov-jdk14-138.jar"/>
                  <resource-root path="bcmail-jdk14-138.jar"/>
                  <resource-root path="antlr-runtime-3.3.jar"/>
                  <resource-root path="antlr-3.3.jar"/>
                  <resource-root path="antlr-2.7.7.jar"/>
              </resources>
          </module>
          

           

          My Module looks like following:

          ========================

           

          AS7.2.0.Alpha1/modules/

          org/

          └── drools

              └── main

                  ├── antlr-2.7.7.jar

                  ├── antlr-3.3.jar

                  ├── antlr-runtime-3.3.jar

                  ├── bcmail-jdk14-138.jar

                  ├── bcprov-jdk14-138.jar

                  ├── commons-collections-3.1.jar

                  ├── dom4j-1.6.1.jar

                  ├── drools-clips-5.3.0.Final.jar

                  ├── drools-compiler-5.3.0.Final.jar

                  ├── drools-core-5.3.0.Final.jar

                  ├── drools-decisiontables-5.3.0.Final.jar

                  ├── drools-jsr94-5.3.0.Final.jar

                  ├── drools-persistence-jpa-5.3.0.Final.jar

                  ├── drools-templates-5.3.0.Final.jar

                  ├── drools-verifier-5.3.0.Final.jar

                  ├── ecj-3.5.1.jar

                  ├── ejb3-persistence-1.0.2.GA.jar

                  ├── google-collections-1.0.jar

                  ├── hibernate-annotations-3.4.0.GA.jar

                  ├── hibernate-commons-annotations-3.1.0.GA.jar

                  ├── hibernate-core-3.3.2.GA.jar

                  ├── hibernate-entitymanager-3.4.0.GA.jar

                  ├── itext-2.1.2.jar

                  ├── javassist-3.12.0.GA.jar

                  ├── jsr94-1.1.jar

                  ├── jta-1.1.jar

                  ├── jxl-2.6.10.jar

                  ├── knowledge-api-5.3.0.Final.jar

                  ├── log4j-1.2.14.jar

                  ├── mvel2-2.1.0.drools4.jar

                  ├── persistence-api-1.0.jar

                  ├── slf4j-api-1.6.0.jar

                  ├── stringtemplate-3.2.1.jar

                  ├── xml-apis-1.3.04.jar

                  ├── xmlpull-1.1.3.1.jar

                  ├── xpp3_min-1.1.4c.jar

                  └── xstream-1.4.1.jar

                  ├── module.xml

           

           

          The Test Application can be found in the following link:   https://github.com/jaysensharma/MiddlewareMagicDemos/tree/master/Drools5.3_Demo_In_JBossAS7

           

          **NOTE:  as the above link contains a WAR which has all the mentioned jars inside the "WEB-INF/lib"  so you will need to alter the attached TestCase a little bit in order to remove the Jars from the WEB-INF/lib  as these jars are now going to be loaded via Module.   Just compare it with your application to see if you are doing anything different.

           

          As you are getting " java.lang.ClassNotFoundException: org.drools.SystemEventListener"  So make sure that te following JAR is added in your drools module because the missing class is available in this jar.  knowledge-api-5.3.0.Final.jar

          • 2. Re: 7.2.0.Final and jboss-deployment-structure.xml
            suikast42

            Hi Jay,

             

            thanks for your contribution. I don't want have the libs in my deployment. I have many testcases which deployed with arquliian. And that save me significant time for all test cases.

             

            You talk about AS7.2.0.Alpha1/modules/. But the modules dir is in 7.2.0.Final  is under ${JBOSS_HOME}/modules/system/layers/base right ??

             

            The problem is if I use jboss-deployment-structure.xml then I get the ClassNotFoundExceeption. And I know where to locate it. But joboss don't .

             

            If I activate the module via standalone.xml in section global modules then it works.

             

            With Jboss 7.1.1.Final jboss-deployment-structure.xml works as expected.

            • 3. Re: 7.2.0.Final and jboss-deployment-structure.xml
              jaysensharma

              Hi,

               

                  I double checked that My Drools Module  is created as my previous comment.   And In the the Test Application I am not placing any JAR inside the WEB-INF/lib    and everything is working just fine for me.    Just try the following once :

               

              Drools5.3_Demo_ModuleBased_JBossAS72_Alpha.zip

               

              Deploy the application on your jboss which has the "org.drools" module as mentioned in m previous comment.  Then access thr application as following:

              http://localhost:8080/DroolsHelloWorldDemo/DroolsInvokerServlet

              • 4. Re: 7.2.0.Final and jboss-deployment-structure.xml
                suikast42

                Hi Jay,

                 

                I'm not at work at moment. I'll try it immediately tomorrow morning. Thanks.

                • 5. Re: 7.2.0.Final and jboss-deployment-structure.xml
                  suikast42

                  Hi Jay,

                  you are right. It works fine for war deployments. But nor for ear deployment.

                   

                  I create a simple ear file and move your war file in it. Delete jboss-deployment-structure.xml from war and move it it ear/META-INF .

                   

                  With the golbal module definition in standalone.xml it works fine but with module definition in jboss-deployment-structure.xml it fails.

                   

                  I look for the version of jboss-modules in 7.1.1.Final it was 1.1.1.GA. The version of  7.2.0.Final is 1.2.0.CR1. So I assume there is a Bug for EAR Deployment.

                   

                   

                  UPDATE:

                   

                  I try the same deployment with the latest stable build of jboss-as-8.0.0.Alpha1-SNAPSHOT. But still the same result the modules version here is 1.2.0.CR2

                   

                   

                  The throwed Exception:

                   

                  javax.servlet.ServletException: JBWEB000248: Servlet execution threw an exception
                  JBWEB000071: root cause 
                  java.lang.NoClassDefFoundError: org/drools/builder/KnowledgeBuilderFactory
                       engine.MyRuleEngine.createKnowledgeBase(Unknown Source)
                       engine.MyRuleEngine.executeRuleEngile(Unknown Source)
                       servlets.DroolsInvokerServlet.service(Unknown Source)
                       javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
                  
                  JBWEB000071: root cause 
                  java.lang.ClassNotFoundException: org.drools.builder.KnowledgeBuilderFactory from [Module "deployment.droolsTest-ear.ear.DroolsHelloWorldDemo.war:main" from Service Module Loader]
                       org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
                       org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:444)
                       org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:432)
                       org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:374)
                       org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:119)
                       engine.MyRuleEngine.createKnowledgeBase(Unknown Source)
                       engine.MyRuleEngine.executeRuleEngile(Unknown Source)
                       servlets.DroolsInvokerServlet.service(Unknown Source)
                       javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
                  
                  

                   


                  • 6. Re: 7.2.0.Final and jboss-deployment-structure.xml
                    jaikiran
                    java.lang.ClassNotFoundException: org.drools.builder.KnowledgeBuilderFactory from [Module "deployment.droolsTest-ear.ear.DroolsHelloWorldDemo.war:main" from Service Module Loader]

                     

                    It's the war that needs that dependency. See these for details on how to set it up:

                     

                    https://issues.jboss.org/browse/AS7-3203

                    https://docs.jboss.org/author/display/AS72/Class+Loading+in+AS7 (search for "Adding a dependency to all modules in an EAR" in there)

                    • 7. Re: 7.2.0.Final and jboss-deployment-structure.xml
                      suikast42

                      Hi Jaikiran,

                       

                      I try it with the export="true" flag. But that's is the same as I define drools as global module.

                       

                      I have problems with log4j with that approach. Something in drools initialiazie log4j before I do it .

                       

                      The strange thing is that this works in 7.1.1.Final. Without the export flag

                      • 8. Re: 7.2.0.Final and jboss-deployment-structure.xml
                        jaikiran

                        Sueleyman Vurucu wrote:

                         

                         

                         

                        I try it with the export="true" flag. But that's is the same as I define drools as global module.

                        It's similar. But I would recommend either using the export flag or explicitly defining the dependency for the sub deployment. I wouldn't suggest using global module.

                         

                         

                        Sueleyman Vurucu wrote:

                         

                         

                        I have problems with log4j with that approach. Something in drools initialiazie log4j before I do it .

                         

                        You mean if you use export, you start seeing a problem? Can you post the entire stacktrace and the updated jboss-deployment-structure.xml?

                         

                         

                        Sueleyman Vurucu wrote:

                         

                         

                        I have problems with log4j with that approach. Something in drools initialiazie log4j before I do it .

                         

                        The strange thing is that this works in 7.1.1.Final. Without the export flag

                        Based on what you are saying, it might have to do with the logging changes that were done post 7.1.1.Final. What happens if you start the server with -Dorg.jboss.as.logging.per-deployment=false

                        • 9. Re: 7.2.0.Final and jboss-deployment-structure.xml
                          suikast42

                          jaikiran pai schrieb:

                          It's similar. But I would recommend either using the export flag or explicitly defining the dependency for the sub deployment. I wouldn't suggest using global module.

                           

                                    What about the jdbc driver ??

                           

                          jaikiran pai schrieb:

                           

                          You mean if you use export, you start seeing a problem? Can you post the entire stacktrace and the updated jboss-deployment-structure.xml?

                           

                           

                              

                          jboss-deployment-structure.xml

                          <jboss-deployment-structure>

                          <!--

                          <ear-subdeployments-isolated>true</ear-subdeployments-isolated>

                          -->

                           

                              <deployment>

                                  <dependencies>

                                      <module name="org.drools" slot="main" />

                                      <module name="org.hibernate" slot="main" />

                                      <!--

                                       -->

                                      <module name="org.infinispan" slot="main" />

                                      <module name="org.jboss.as.clustering.infinispan" slot="main" />

                                  </dependencies>

                              </deployment>

                          </jboss-deployment-structure>

                           

                          jaikiran pai schrieb:

                           

                          Based on what you are saying, it might have to do with the logging changes that were done post 7.1.1.Final. What happens if you start the server with -Dorg.jboss.as.logging.per-deployment=false

                           

                           

                          I had have switch back to 7.1.1.Final I'll switch back to 7.2.0.Final to tell you more.

                           

                          My Problem with Log4j and Jboss logging is that I can't use the addivity flag of the log4j loggers. The JBoss BridgeLogger ignore that falg. With other words this falg don't take a efect.