1 Reply Latest reply on Feb 16, 2016 2:56 AM by tariq.iitr

    Loading my custom jar before ear is deployed in jboss -eap -6.4

    tariq.iitr

      Hi

       

      We are migrating our application from jboss eap 5.1.2 to jboss-eap-6.4.

       

      In my application , slf4j-1.5.6-api.jar is bundled but one of our custom class requires slf4j-1.6.1-api.jar to get initialized. In current setup i.e. jboss-eap-5.1.2 , we have placed slf4j-1.6.1-api.jar in jboss/server/<profile>/lib so that it is loaded first and all the depencies are resolved from this jar.


      in to be setup, application build script is disabling loading of jboss slf4j module so that lib which is present in ear/lib i.e. 1.5.6 is loaded .

      now when i am trying to load slf4j-1.6.1-api.jar as an external module by adding it in jboss-deployment-structure.xml , i am getting conflict as /org/slf4j/Logger class is getting initialized from slf4j-1.5.6-api.jar & ILoggerFactory from 1.6.1 & deployment is failing.  Below is the sequence from log.

       

      INFO   | jvm 1    | 2016/02/12 11:04:50 | [Loaded org.slf4j.LoggerFactory from vfs:/content/smcfs.ear/lib/slf4j-api-1.5.6.jar]

      INFO   | jvm 1    | 2016/02/12 11:04:50 | [Loaded org.slf4j.ILoggerFactory from jar:file:/app/jboss-eap-6.4/modules/walmart/common/main/slf4j-api-1.6.1.jar!/]

       

      Error

       

      lt-host].[/sbc]] (ServerService Thread Pool -- 58) JBWEB000284: Exception starting filter StrutsLocaleSettingFilter: java.lang.NoSuchMethodError: org.slf4j.helpers.Util.reportFailure(Ljava/lang/String;Ljava/lang/Throwable;)V

       

      As a workaround i tried deployment after removing the slf4j-api-1.5.6.jar from ear/lib thinking that Logger class will be initialized from external madule but it is failing .

       

      Error

      INFO   | jvm 1    | 2016/02/14 04:27:13 | Caused by: java.lang.RuntimeException: JBAS018757: Error getting reflective information for class com.sterlingcommerce.ui.web.framework.servlets.SCUIETagSupportServlet with ClassLoader ModuleClassLoader for Module "deployment.smcfs.ear.sbc.war:main" from Service Module Loader

      INFO   | jvm 1    | 2016/02/14 04:27:13 |       at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:72) [jboss-as-server-7.5.0.Final-redhat-21.jar:7.5.0.Final-redhat-21]

       

      INFO   | jvm 1    | 2016/02/14 04:27:13 |       at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:159) [jboss-as-server-7.5.0.Final-redhat-21.jar:7.5.0.Final-redhat-21]

      INFO   | jvm 1    | 2016/02/14 04:27:13 |       ... 5 more

      INFO   | jvm 1    | 2016/02/14 04:27:13 | Caused by: java.lang.NoClassDefFoundError: Lorg/slf4j/Logger;

      INFO   | jvm 1    | 2016/02/14 04:27:13 |       at java.lang.Class.getDeclaredFields0(Native Method) [rt.jar:1.8.0_51]

      INFO   | jvm 1    | 2016/02/14 04:27:13 |       at java.lang.Class.privateGetDeclaredFields(Class.java:2583) [rt.jar:1.8.0_51]

       


      Looks like modules jars (slf4j-api-1.6.1.jar & slaf4j-slf4j-log4j12-1.6.4.jar) are getting loaded  after ear/lob jars but as per jboss documentation modules should be loaded first so i am not sure how to fix this issue. Can anyone suggest any solution to fix this issue?


      One option which i can think of packaging these modules jar as ear/lib but that would require the application build process change which i want to go for as last option as i do not know if there is any other jar which would need slf4j-api-1.5.6.jar.


      If i can load modules jar before ear/lib then i guess i can solve this problem.


      My module.xml is as below.


      <?xml version="1.0" encoding="UTF-8"?>

      <module xmlns="urn:jboss:module:1.1" name="my.common">

              <resources>

                      <resource-root path="environment.jar"/>

                      <resource-root path="slf4j-api-1.6.1.jar"/>

                      <resource-root path="slf4j-log4j12-1.6.4.jar"/>

              </resources>

               <dependencies>

              <module name="org.apache.log4j"/>

              </dependencies>

      </module>

       

      And ear jboss-deployment-structure.xml as below

      <?xml version="1.0" encoding="UTF-8"?>

      <jboss-deployment-structure>

          <deployment>

              <dependencies> 

                    <module name="walmart.common" />

              </dependencies> 

        <exclusions>

                  <module name="org.apache.log4j"/>

                  <module name="org.jboss.log4j"/>

                  <module name="org.jboss.log4j.logmanager"/>

                  <module name="org.jboss.logmanager"/>

                  <module name="org.jboss.logging"/>

                  <module name="org.slf4j"/>

                  <module name="org.jboss.logging.jul-to-slf4j-stub"/>

                  <module name="org.javassist"/>

              </exclusions>

          </deployment>

          <sub-deployment name="smcfs.war">

              <exclusions>

                  <module name="org.apache.log4j"/>

                  <module name="org.jboss.log4j"/>

                  <module name="org.jboss.log4j.logmanager"/>

                  <module name="org.jboss.logmanager"/>

                  <module name="org.jboss.logging"/>

                  <module name="org.slf4j"/>

                  <module name="org.jboss.logging.jul-to-slf4j-stub"/>

                  <module name="org.javassist"/>

              </exclusions>

          </sub-deployment>

          <sub-deployment name="sbc.war">

              <exclusions>

                  <module name="org.apache.log4j"/>

                  <module name="org.jboss.log4j"/>

                  <module name="org.jboss.log4j.logmanager"/>

                  <module name="org.jboss.logmanager"/>

                  <module name="org.jboss.logging"/>

                  <module name="org.slf4j"/>

                  <module name="org.jboss.logging.jul-to-slf4j-stub"/>

                  <module name="org.javassist"/>

              </exclusions>

          </sub-deployment>

      </jboss-deployment-structure>

       

      Any help/suggestion is highly appreciated.

      Thanks

        • 1. Re: Loading my custom jar before ear is deployed in jboss -eap -6.4
          tariq.iitr

          I could solve this problem by loading my external jars as jboss global module. added below content in standalone.xml config file under urn:jboss:domain:ee subsystem.

           

          <subsystem xmlns="urn:jboss:domain:ee:1.2">

                      <spec-descriptor-property-replacement>false</spec-descriptor-property-replacement>

                      <jboss-descriptor-property-replacement>true</jboss-descriptor-property-replacement>

                      <annotation-property-replacement>false</annotation-property-replacement>

                       <global-modules>

                          <module name="mycompany.common" slot="main"/>

                       </global-modules>

                  </subsystem>

           

           

          I just want to understand, as per jboss documentations , external modules defined in jboss-deployment-descritptor.xml are loaded  before ear/lib jars but when i put the verbose trace on, i see that ear/lib jars are loaded before the external modules and that's where i faced this issue.