9 Replies Latest reply on Sep 16, 2011 7:52 AM by anonym127

    problem with web app classloader isolation

    Ma Va Newbie

      Hi,

       

      I have a problem with my web application classloader isolation.

       

      I would like to have separated classloader for my WAR, which will at first try to load classes from [WAR file]/WEB-INF/lib and [WAR file]/WEB-INF/classes. If it doesn't find the class there, it will delegate the request to it's parent which should be some JBoss default classloader.

      I definitely don't want to share libraries with any other application deployed in the JBoss.

      Is it even possible?

       

      My Jboss version is jboss-6.0.0

      I didn't change any configuration in the default installation.

       

      In WAR file, I've tried these config xmls:

       

      [WAR file]/WEB-INF/jboss-classloading.xml

      <?xml version="1.0" encoding="UTF-8"?><classloading xmlns="urn:jboss:classloading:1.0"

        name="myapp.war" 
        domain="myapp.war"
        parent-domain="DefaultDomain
        export-all="NON_EMPTY"
        import-all="false"
        parent-first="false" >

      </classloading>

       

      [WAR file]/WEB-INF/jboss-web.xml

      <jboss-web>

        <class-loading java2ClassLoadingCompliance="false">
          <loader-repository>com.myapp:archive=myapp
            <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
          </loader-repository>
        </class-loading>

      </jboss-web>

       

      However it doesn't help.

      My app ends with this message:

       

      Deployment "vfs:///home/user/soft/jboss-6.0.0.Final/server/default/deploy/myapp.war" is in error due to the following reason(s): java.lang.ClassNotFoundException: 1.0.com.sun.codemodel.JConditional

       

      ... of course class 1.0.com.sun.codemodel.JConditional is in one of the jars in the WEB-INF/lib/

      And many other applications don't work as well.Problem probably is, that libraries loaded by myapp classloader are shared by other applications so the log is full of these(or similar) error messages:

      Deployment "vfs:///home/user/soft/jboss-6.0.0.Final/server/default/deploy/hornetq/jms-ds.xml" is in error due to the following reason(s): java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "javax/transaction/xa/XAResource"

       

      Could you please suggest the working way how to isolate the classloaders as I described above?

       

      Thanks,

      Martin

        • 2. problem with web app classloader isolation
          jaikiran pai Master

          Ma Va wrote:

           

          Hi,

           

          I have a problem with my web application classloader isolation.

           

          I would like to have separated classloader for my WAR, which will at first try to load classes from [WAR file]/WEB-INF/lib and [WAR file]/WEB-INF/classes. If it doesn't find the class there, it will delegate the request to it's parent which should be some JBoss default classloader.

          I definitely don't want to share libraries with any other application deployed in the JBoss.

          Is it even possible?

          You need any addition configurations for that to work in JBoss AS6. That's the default behaviour.

           

           

           

          Ma Va wrote:

           

          However it doesn't help.

          My app ends with this message:

           

          Deployment "vfs:///home/user/soft/jboss-6.0.0.Final/server/default/deploy/myapp.war" is in error due to the following reason(s): java.lang.ClassNotFoundException: 1.0.com.sun.codemodel.JConditional

           

          ... of course class 1.0.com.sun.codemodel.JConditional is in one of the jars in the WEB-INF/lib/

          I've now seen this specific class numerous times being reported. It was reported (for a different reason) in AS5 too. The culprit jar is  some jaxb-xjc*.jar which might be present in your application .war file. Try removing that jar. That jar has a weird packaging. In the meantime I'll see if we can get rid of that CNFE within JBoss AS (my guess is that the scanning mechanism is considering 1.0 as a package name identifier).

           


          Ma Va wrote:

           


           

          Deployment "vfs:///home/user/soft/jboss-6.0.0.Final/server/default/deploy/hornetq/jms-ds.xml" is in error due to the following reason(s): java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "javax/transaction/xa/XAResource"

           

          Do not package any jar file(s) containing javax.transaction.* classes in your application. Those are API jars which are already shipped in the server and are expected to be picked up from the server lib directory.

          • 3. problem with web app classloader isolation
            jaikiran pai Master

            Dinuka Arseculeratne wrote:

             

            this link might be helpful;

             

            http://ramya.bhaavana.net/chaitanya/archives/000021.html

             

            Just a FYI - most of the details in that article are way outdated (not blaming that article since it was written way back in 2003).

            • 4. problem with web app classloader isolation
              Ma Va Newbie

              I removed jta.jar, jaxb-xjc.jar.

              Then I had some problems with hibernate and JPA,

              so I had to remove my hibernate 3.2 jars and use hibernate 3.6 included in jboss.

              Also I had to add some JPA configuration parameters.

              However jboss finally started my app.

               

              Thanks for your help.

              Martin

              • 5. Re: problem with web app classloader isolation
                rop Newbie

                Hi,

                 

                I just encountered this

                     ClassNotFoundException: 1.0.com.sun.codemodel.JConditional

                too, when trying to migrate from tomcat too jboss-6.

                 

                Just wondered, when you say "remove jar from your war-file..."

                is it possible in maven to specify such exclusion of specific jar-files during packaging?

                 

                Or do you remove them manually from the war-file after the build? Or how...?

                • 6. Re: problem with web app classloader isolation
                  Ma Va Newbie

                  Hi,

                   

                  I use ant so I specified exclusions for jboss in ant build script.

                  I dont use maven, and I dont know anything about it, however I believe it can do it too.

                   

                  M.

                  • 7. Re: problem with web app classloader isolation
                    Newbie

                    Hi,

                    I'm using JBoss AS 6.1.0 and have the same problem. Just with JBreak class instead of JConditional.

                     

                    DEPLOYMENTS IN ERROR:

                      Deployment "vfs:///D:/jboss-6.1.0.Final/server/marzipan1/deploy/marzipanapp.ear" is in error due to the following reason(s): java.lang.ClassNotFoundException: 1.0.com.sun.codemodel.JBreak

                     

                     

                    I can't apply the solution of Ma Va. If I delete jaxb-xjc.jar, I'm getting the following result:

                     

                    The server is booting (I'm getting correct output in boot.log), but after the correct boot nothing happens anymore. The server is in a indefinite loop (it's doing something, since the cpu usage is > 0 ).

                     

                    Problem: I don't get any output, so I don't get any errors to fix.

                     

                    Hint: I have a hibernate-jpa-2.0-api-1.0.0.Final.jar in my lib-Folder. Should I try a newer one?

                     

                    J.

                    • 8. Re: problem with web app classloader isolation
                      hai qing Newbie

                      I also have the proplem,how to solve?

                      • 9. Re: problem with web app classloader isolation
                        Newbie

                        I gave up. We are waiting now for AS7 for the migration. AS7 is much better anyways.