7 Replies Latest reply on Mar 20, 2010 6:26 AM by jaikiran pai

    JBoss 4.2.2 ignoring jboss-web.xml in grails war

    Brian Gardner Newbie

      We have an existing JBoss application that is running in 4.2.2 using EJB3. I am trying to add a Grails war file to that deployment for some admin forms. As you may know, the versions of hibernate (particularly the annotation jar) are not compatible. I tried replacing the JBoss server's libraries, but then the existing (in production) application stops working.

       

      Another poster suggested that I tell JBoss to isolate classpaths for the added application by adding the following to jboss-web.xml in the Grails application's WEB-INF directory, and this would tell JBoss to use a separate classloader. Sounds like exactly what I need, except that JBoss is ignoring this setting.

       

      [Loaded org.hibernate.validator.ClassValidator from file:/C:/Jboss/jboss-4.2.2.GA.VZWDEV/server/default/lib/hibernate-annotations.jar]

       

      Here is what is in my jboss-web:

      <jboss-web>
           <class-loading>
               <loader-repository>
                   com.vzw.acsr:loader=acsradmin.war<loader-repository-config>java2ParentDelegation=false</loader-repository-config>
               </loader-repository>
           </class-loading>
      </jboss-web>

       

      This should be working, as others have reported, but in my case it does not. Does anyone have any ideas?

       

      Brian

        • 1. Re: JBoss 4.2.2 ignoring jboss-web.xml in grails war
          jaikiran pai Master

          Given the refactoring that was done in Hibernate libraries, isolating them correctly, is a bit more involved. Here's what you have to do http://community.jboss.org/thread/64126?tstart=0

          • 2. Re: JBoss 4.2.2 ignoring jboss-web.xml in grails war
            Brian Gardner Newbie

            jaikiran wrote:

             

            Given the refactoring that was done in Hibernate libraries, isolating them correctly, is a bit more involved. Here's what you have to do http://community.jboss.org/thread/64126?tstart=0

            Jaikiran,

             

            I read that series of postings, and my basic question is still not answered. I set up the jboss-web.xml as you recommended:

             

            <jboss-web>
                <context-root>/</context-root>
                 <class-loading java2ClassLoadingCompliance="false">
                     <loader-repository>
                         com.vzw.acsr:loader=acsradmin.war<loader-repository-config>java2ParentDelegation=false</loader-repository-config>
                     </loader-repository>
                 </class-loading>
            </jboss-web>

             

            and the result is the same. I get the following error when the Grails app deploys

             

            java.lang.NoSuchMethodException: org.hibernate.validator.ClassValidator.<init>(java.lang.Class, java.util.ResourceBundle, org.hibernate.validator.MessageInterpolator, java.util.Map, org.hibernate.annotations.common.reflection.ReflectionManager)

             

            The war has the new (grails-friendly) hibernate-validations.jar included in its lib directory, but the one in the JBOSS/default/lib is the one that gets loaded each time. I have confirmed that the jars are where they are supposed to be.

             

            Adding "-verbose:class" to the JAVA_OPTS reveals the truth:

            [Loaded org.hibernate.validator.ClassValidator from file:/C:/Jboss/jboss-4.2.2.GA.VZWDEV/server/default/lib/hibernate-annotations.jar]

             

            This is not the location that grails needs, and the isolation appears to be ignored, but I wonder if this is loaded before the jboss-web.xml is even looked at.I do see that library being loaded, but it appears that only classes to don't exist in the default one are being loaded, as in the following:

            [Loaded org.hibernate.cfg.RecoverableException from file:/C:/Jboss/jboss-4.2.2.GA.VZWDEV/server/default/tmp/deploy/tmp7080372592080756625acsradmin-exp.war/WEB-INF/lib/hibernate-annotations-3.4.0.GA.jar]

             

            This confirms that the jar is getting read, but only certain classes are being loaded from it, not the ClassValidator class that creates the exception above.

             

            If I remove/replace the old version of the jar from the default lib my existing application (which is not really mine in the first place) starts crashing.

             

            Which part of that posting you referenced was supposed to contain the part that I'm missing?

             

            I appreciate your response,

             

            Brian

            • 3. Re: JBoss 4.2.2 ignoring jboss-web.xml in grails war
              jaikiran pai Master

              bgardner wrote:


               

              Which part of that posting you referenced was supposed to contain the part that I'm missing?

              The part which lists down the various hibernate jars and their versions that need to be included in your app, to get the isolation right

               

              Let's try this, post the output of

               

              jar -tf myapp.war
              

               

              myapp.war is the name of your war file. Also post the version of various hibernate jars that you are including your application.

              • 4. Re: JBoss 4.2.2 ignoring jboss-web.xml in grails war
                Brian Gardner Newbie

                The existing ear uses the following hibernate jars, which I believe originate from the JBoss installation:

                hibernate3.jar
                hibernate-annotations.jar
                hibernate-ejb3-persistence.jar
                hibernate-entitymanager.jar
                hibernate-metadata.jar

                 

                The new grails war uses the following hibernate jars:

                hibernate-annotations-3.4.0.GA.jar
                hibernate-commons-annotations-3.3.0.ga.jar
                hibernate-core-3.3.1.GA.jar

                 

                The particular jar of conflict is the annotations jar, though I'm aware that there could be others that we are not seeing. Even when I try to isolate that jar the jar in the default/lib is picked up first, and not overidden by the war file. What I'm considering as a next move is to put the (older) jars in the ear file distribution and placing the new hibernate files in the war, since the ear's manifest can specify the libraries that are local to the ear more readily.

                 

                The output you requested is attached. Thanks for your assistance.

                 

                Brian

                • 5. Re: JBoss 4.2.2 ignoring jboss-web.xml in grails war
                  jaikiran pai Master

                  So you have an .ear within which this .war is placed? In that case, the jboss-web.xml in .war will be ignored. If i understand your packaging correctly:

                   

                  1) you are having a set of hibernate jars with a different version in the .ear

                  2) The .ear has a .war file with another set of hibernate jars files of different version

                   

                  Is that correct?

                  • 6. Re: JBoss 4.2.2 ignoring jboss-web.xml in grails war
                    Brian Gardner Newbie

                    Jaikiran,

                     

                    No, the war is not placed in the ear. The war is in the deploy directory separate from the ear file, which is a different application. So it looks like this:

                     

                    default

                        deploy

                            _ears

                                MyApplication.ear - (using older hibernate versions)

                                            MyOtherApplication.ear

                            MyGrailsApp.war - (using new hibernate versions)

                     

                    Hope that makes this clearer.

                     

                    Brian

                    • 7. Re: JBoss 4.2.2 ignoring jboss-web.xml in grails war
                      jaikiran pai Master

                      I should have looked more closely at your config file. It seems to be incorrect:

                       

                      <jboss-web>
                           <class-loading>
                               <loader-repository>
                                   com.vzw.acsr:loader=acsradmin.war<loader-repository-config>java2ParentDelegation=false</loader-repository-config>
                               </loader-repository>
                           </class-loading>
                      </jboss-web>

                       

                       

                      As per the wiki http://community.jboss.org/wiki/classloadingconfiguration :

                       

                      *Note: As of at least JBoss 4.2.1, the <class-loading> tag appears to no longer be supported as isolation is ignored. Instead, the following configuration appears to accomplish the same goal:

                       
                      <jboss-web>
                         <loader-repository> 
                            com.example:archive=unique-archive-name 
                         </loader-repository> 
                      </jboss-web> 
                      

                       

                      I'll update that wiki to add this sentence in bold. Give it a try and see if it solves your issue. If not, let's see what else might be causing it.