7 Replies Latest reply on Jan 20, 2011 4:10 AM by nchivukula

    JBoss Web Applications Classloader Conflict

    nchivukula

      Hi All,

       

      I have been working on JBoss 5.1 quite some time and at the moment working on JAX-WS web services deployment. I'll state my question simple and elaborated for suitable readers.

      Simple:

      In my Jboss server deploy directory, I have few web applications (web applications include web service applications). In one, I used classloader isolation giving domain name my web application context, which should make Jboss server load the web application jars first and then server jars next if I'm not wrong. This particular web application having classloader isolation is causing server runtime issues(ExceptionInInitializerError of one of the classes present in WEB-INF/lib jars) when other web application already deployed is tested! I'm stunned by this as web applications normally have their own classloaders. Then, if I back out the problem web application, then the other works fine. Can someone explain or point to some link where I can study JBoss classloader mechanism in easily understandable version?

       

      Elaborated:

      Hoping you read above, I have few web service applications (all created using JAX-WS) running on JBoss 5.1. The web service jar files that these applications use are (in WEB-INF/lib directory)

      (JAX-WS 2.1 API libraries)

      webservices-api.jar

      webservices-extra-api.jar

      (JAX-WS 2.1 Runtime libraries Project Metro 1.1)

      webservices-rt.jar

      webservices-extra.jar

       

      And the above web service applications don't have any class loader isolation.

       

      I have a new web service A, which was tested on a different box on same JBoss 5.1 server but has no other web services applications. The web service jar files that this web application use is (in WEB-INF/lib directory)

      jaxws-rt.jar

      stax-ex.jar

      streambuffer.jar

       

      This web serivce application A has got class loader isolation.

      When the new web service A is deployed with earlier web service applications, I get ExceptionInInitializerError when testing one of the earlier web service applications. The stack trace is as shown in the attached log. Obviously, it complains of having two classes with same @XmlType.name element annotations. But, those two classes are contained in two different jars, each in a different web application. They shouldn't conflict in any case. But, when I remove classloader isolation and add the four jars like in earlier web service applications, this works fine. Now, I should not be bothered of wondering all this why it failed in first case. But, I want to understand how JBoss works! Any thoughts highly appreciated.

       

      Cheers,

      Naren Chivukula

        • 1. JBoss Web Applications Classloader Conflict
          alesj
          Can someone explain or point to some link where I can study JBoss classloader mechanism in easily understandable version?

          * http://java.dzone.com/articles/jboss-microcontainer-classloading

          • 2. Re: JBoss Web Applications Classloader Conflict
            nchivukula

            Thank Ales for the link.

             

            I couldn't actually fit that documentation to my problem context. All I'm looking forward for someone to answer is how one web application classpath does affect others?

             

            Cheers,

            Naren

            • 3. Re: JBoss Web Applications Classloader Conflict
              alesj
              All I'm looking forward for someone to answer is how one web application classpath does affect others?

              All apps in JBoss share common classloading DefaultDomain.

              In web' case, we actually create child CL domain for each web app,

              while properly setting up the domain parent policy; e.g. child first.

               

              As such the web apps resources shouldn't be seen to other apps.

              Unless you change the default rules, and make your web app part of DefaultDomain.

              This was the case before with .ear (its root classpath) and other non web apps (.jar, .rar, .sar, ...).

               

              The common/shared classes are loaded on first-found basis,

              which might be potential problem, if apps share diff versions of "same" classes.

               

              From your description it's unfortuantely impossible to see what's going on.

              • 4. Re: JBoss Web Applications Classloader Conflict
                alesj
                This was the case before with .ear (its root classpath) and other non web apps (.jar, .rar, .sar, ...).

                We changed the .ear behavior to be isolated by default in AS6,

                but the rest - .jar, .sar, ... - is still the same --> shared.

                • 5. Re: JBoss Web Applications Classloader Conflict
                  nchivukula

                  Thanks Ales.

                   

                  Yes, I used classloader isolation for my problem web service as shown below (A refers to problem web service).

                  <classloading xmlns="urn:jboss:classloading:1.0"

                      domain="A"

                      export-all="NON_EMPTY"

                      import-all="true">

                  </classloading>

                   

                  Does this help to understand what went wrong?

                  • 6. Re: JBoss Web Applications Classloader Conflict
                    alesj
                    Yes, I used classloader isolation for my problem web service as shown below (A refers to problem web service).

                    <classloading xmlns="urn:jboss:classloading:1.0"

                        domain="A"

                        export-all="NON_EMPTY"

                        import-all="true">

                    </classloading>

                     

                    Does this help to understand what went wrong?

                    This just means it's isolated == other deployments don't see its resources.

                    But the delegation model is still parent-first=true.

                    • 7. Re: JBoss Web Applications Classloader Conflict
                      nchivukula

                      Thanks for your quick reply.

                       

                      That's the problem Ales. Even I isolated this(A) web application and tried deploying, because other of conflicts with other web application jars this(A) web application deployment is getting failed. Does this mean parent classloader also hold other web application's classes?