9 Replies Latest reply on Sep 14, 2015 12:09 PM by jamezp

    Could not initialize class org.jboss.logmanager.MDC on Wildfly 9

    chandrasachin16

      Hi All,

       

       

      I am facing one issue of java.lang.NoClassDefFoundError: Could not initialize class org.jboss.logmanager.MDC in WildFly 9.

      My application consists of an ear (having a war file) which works on JBOSS AS 7.Server starts up successfully and I can access my webservices via SOAP UI.I can send request and get response successfully.


      The same ear if I deploy on Wildfly 9 also gets deployed successfully,but when I access my webservices and try to send some request via the SOAP UI gives me the below error.

       

      Could not initialize class org.jboss.logmanager.MDC: java.lang.NoClassDefFoundError: Could not

      initialize class org.jboss.logmanager.MDC

              at org.slf4j.impl.Slf4jMDCAdapter.put(Slf4jMDCAdapter.java:32)

              at org.slf4j.MDC.put(MDC.java:116)

              at com.te.framework.core.BasicWorkflowStrategy.preliminary(BasicWorkflowStrategy.java:78)

              at com.te.framework.core.BasicWorkflowStrategy.invokeOn(BasicWorkflowStrategy.java:43)

              at com.te.framework.core.AbstractService.invoke(AbstractService.java:217)

       

      I have not changed anything in the packaging structure of my ear .It's just the same ear which is working on AS7. As far as I can see the slf4j jar versions have changed if I compare AS7 with Wildfly 9.It seems class loading issue but what is  causing this issue.Can anybody please suggest me what could be wrong .

       

       

      Regards

      Sachin

        • 1. Re: Could not initialize class org.jboss.logmanager.MDC on Wildfly 9
          jamezp

          Are you excluding the org.slf4j module and including your own by chance?

           

          --

          James R. Perkins

          • 2. Re: Could not initialize class org.jboss.logmanager.MDC on Wildfly 9
            chandrasachin16

            Hi ,

            First of all thanks for your reply.As far as excluding the org.slf4j module is concerned I am not excluding it. I don't have jboss-deploymemt-structure.xml in my ear to exclude it ,neither I am adding any explicit dependencies via the jboss-deploymemt-structure.xml.

             

            What surprises me is that my ear works fine on JBoss AS 7 i.e gets deployed successfully and I can access my webservices,send request and get response but, face issues with the same ear (with no changes) on Wildfly 9. My ear gets deployed on Wildfly 9 , I can also see my wsdl up in browser (deployment is fine ) but, when I send a request via SOAP UI to test the response  gives me this issue.

             

            I moved to Wildfly because I have an MDB packaged in jar inside my ear for which I wanted to keep the MDB configurations like destination name(queue name) etc externalized i.e to be inside the server configuration ( in standalone-full.xml which I have already done)

            Since the above configuration cannot be done in AS 7 so I moved to Wildfly as it provides a lot many new features.

            • 3. Re: Could not initialize class org.jboss.logmanager.MDC on Wildfly 9
              jamezp

              I'm not sure what the difference would be. Nothing has changed with regards to logging dependencies. I don't know much about how web service implementation works, but maybe it's not copying some context over if it's creating new threads or something. Also make sure you don't have a slf4j library in your EAR.

               

              --

              James R. Perkins

              • 4. Re: Could not initialize class org.jboss.logmanager.MDC on Wildfly 9
                chandrasachin16

                Hi,

                 

                Ok now I understand your point when you say ( slf4j library in ear ). My ear structure is as below

                 

                AccountEAR.ear

                          ------  META-INF

                                  jcl-over-slf4j-1.5.8.jar

                                  log4j-1.2.16.jar

                                  slf4j-api-1.5.8.jar

                                  slf4j-log4j12-1.5.8.jar

                                  AccountWeb.war

                                             ------WEB-INF

                                                        ------lib

                                                               ---- AccountEjb.jar

                                                               -----other jars

                 

                There were 4 jars in my ear which were added in maven dependency ( not sure why it was added) . I changed the packaging structure by moving it into my war as below but still I see the same error. Could this be the error related to slf4j version since my application has different version and Wildfly has different one.

                 

                AccountEAR.ear

                          ------  META-INF

                                  AccountWeb.war

                                                 ------WEB-INF

                                                                ------lib

                                                                AccountEjb.jar

                                                                jcl-over-slf4j-1.5.8.jar

                                                                log4j-1.2.16.jar

                                                                slf4j-api-1.5.8.jar

                                                                slf4j-log4j12-1.5.8.jar

                                                                -----other jars

                 

                I am still wondering how was it working on AS 7.

                 

                Regards

                Sachin

                • 5. Re: Could not initialize class org.jboss.logmanager.MDC on Wildfly 9
                  chandrasachin16

                  Hi,

                   

                  On more thing I found from the logs which seems interesting -

                  From the logs what I see in below steps which executes during class loading  ---

                   

                  Loading class org.slf4j.MDC locally from Module "org.slf4j:main"

                  Attempting to define class org.slf4j.MDC in Module "org.slf4j:main"

                  Defined class org.slf4j.MDC in Module "org.slf4j:main" from local module loader

                  Finding class org.slf4j.spi.MDCAdapter from Module "org.slf4j:main"

                  Finding local class org.slf4j.spi.MDCAdapter from Module "org.slf4j:main"

                   

                  ------------- continue------

                   

                  Loading class org.slf4j.impl.Slf4jMDCAdapter  (It gets the Adapter from the Wildfly)

                  Attempting to define class org.slf4j.impl.Slf4jMDCAdapter

                  Defined class org.slf4j.impl.Slf4jMDCAdapter in Module "org.slf4j.impl:main"

                  Finding class org.jboss.logmanager.MDC from Module "org.slf4j.impl:main"

                  Finding local class org.jboss.logmanager.MDC from Module "org.jboss.logmanager:main"

                   

                  but then it didn't loaded the class org.jboss.logmanager.MDC and blows up.

                   

                  Now as I have removed the slf4j jars from my ear and placed in my war in the WEB-INF/lib folder, so I was expecting it to work properly.From logs it seems the jars from Wildfly are loading properly till org.slf4j.impl.Slf4jMDCAdapter but blows up when it tries to load

                  class org.jboss.logmanager.MDC

                   

                  Regards

                  Sachin

                  • 6. Re: Could not initialize class org.jboss.logmanager.MDC on Wildfly 9
                    chandrasachin16

                    Hi,

                    I tried one more thing. In maven dependency I did something like this---

                     

                    <dependency>

                      <groupId>org.slf4j</groupId>

                      <artifactId>jcl-over-slf4j</artifactId>

                    <version>${slf4j.version}</version>

                      <scope>provided</scope>     // earlier it was compile in place of provided so changed it to provided and also changed to version to 1.7.7.The slf4j is required by my axis which builds my webservices.

                     

                    So this removed the slf4j jar in my packaged ear.This does not add any dependency of jar in my ear but, will add the jar provided by my Wildfly server at runtime which is correct way to do but, I still see the same problem with Wildfly 9.0.0 .

                    Also tried on WildFly 9.0.1 but same behaviour. But same ear works fine on AS 7.

                     

                    Regards

                    sachin

                    • 7. Re: Could not initialize class org.jboss.logmanager.MDC on Wildfly 9
                      jamezp

                      I just did a test with slf4j and using org.slf4j.MDC on WildFly 9.0.1.Final and didn't have any issues. Make sure you don't have any of the logging libraries you described above in your deployment. All those will be provided by the container by default.

                       

                      --

                      James R. Perkins

                      • 8. Re: Could not initialize class org.jboss.logmanager.MDC on Wildfly 9
                        chandrasachin16

                        Hi ,

                         

                        As you suggested I removed those jars but again had those issues.But let me explain you one very interesting thing which I saw while I was doing some trick.

                         

                        I exported myAccountEjb.jar as a jar file from my eclipse and deployed it it WildFly restarted my server and tried to a put a message.It worked fine without issues.Then I removed this jar without stopping my server and deployed that very same ear which was running into issues.The ear got deployed and this time I again tested the webservices via SOAP UI and this time it worked without issues.It was able to load the org.jboss.logmanager .

                         

                        What happened with this trick I am not able to understand,but can you throw some light on this.

                        Though it is not a solution and it's just a trick but can you please let me know any findings from you end.

                         

                         

                        Regards

                        sachin

                        • 9. Re: Could not initialize class org.jboss.logmanager.MDC on Wildfly 9
                          jamezp

                          Well from my simple test it works fine. I'm just using a servlet though. I see no reason why that class wouldn't be found unless the wrong SLF4J implementation model is being used.

                           

                          --

                          James R. Perkins