3 Replies Latest reply on May 15, 2009 11:06 AM by ben_leedham

    Ear as a loader repository

      Hi,

      I am deploying an EAR file containing several WAR files. the EAR contains all the libraries necessary for the WARs, 2 of those libraries being specific saaj api and impl versions.

      When I try to start the server I get a NoSuchMethodError, as the saaj version being loaded is from jboss-4.0.3SP1/server/default/lib/jboss-saaj.jar, and not from the EAR's APP-INF/lib.

      If I put the saaj jars in the WEB-INF/lib of each of the wars all is fine, but that is a messy solution.

      I have tried creating a jboss-app.xml file alongside my application.xml file in the EAR's META-INF directory with this content:

      <jboss-app>
       <loader-repository>
       hello:service=LoaderRepository
       <loader-repository-config>
       java2ParentDelegation=false
       </loader-repository-config>
       </loader-repository>
      </jboss-app>


      Essentially what I am trying to achieve is for the EAR to be a loader repository and not look at the parent server for it's jars.

      This doesn't work and I don't understand what I am doing wrong. Any help would be appreciated.

      Cheers.

        • 1. Re: Ear as a loader repository

          I have been searching around and not been able to find much that is particularly in depth about how to configure the classloading for jboss.

          I have read through this:

          http://www.jboss.org/community/wiki/ClassLoadingConfiguration

          and tried configuring my jboss-app.xml accordingly, by pointing the class that is giving me NoSuchMethodError explicitly at the jar I want it loaded from ( e.g. javax.xml.soap.SOAPElement:loader=myearapp.ear and javax.xml.soap.SOAPElement:archive=saaj-api-1.3.jar ).

          This doesn't appear to work in the jboss-app.xml at EAR level but only in the jboss-web.xml at WAR level ( e.g. javax.xml.soap.SOAPElement:loader=mywarapp.war ) with the libraries in the WEB-INF/lib, and I have a feeling that is because that is the first place searched for classes.

          I have also read this:

          http://www.weiqigao.com/articles/jboss/foil18.html

          and tried using that suggestion in the jboss-app.xml, it did appear to have some affect but not the desired one of looking at the EAR for classes prior to the app server.

          I have also read the jboss-app DTD from here:

          http://www.jboss.org/j2ee/dtd/ ( then the jboss-app_4_0.dtd for my version )

          which gives me info about the elements allowed with in the jboss-app.xml but gives no extra information on the values that are valid within those elements.

          If anyone could provide me with more information about jboss classloading or specifically about the values that are appropriate for the jboss-app.xml loader-repository tag it would be very helpful indeed. this is a bit of a classloading nightmare.

          Cheers.

          • 2. Re: Ear as a loader repository
            jaikiran

             

            and not from the EAR's APP-INF/lib.


            The APP-INF folder is not identified by JBoss. I guess it's specific to WebSphere.

            jboss-4.0.3SP1


            Any specific reason why you are using a old version of JBoss? In this version of JBoss, i guess you can create a "lib" folder at the root of the EAR and then add all the necessary jars to this lib folder. You will additionally have to mark all these jars as a java module in the application.xml:
            <module>
             <java>lib/saaj.jar</java>
            </module>

            You might sometimes need to scope the classloaders (through jboss-app.xml) if you are packaging any jars which are already provided by JBoss.


            In JBoss-4.2.x, this is much easier. You can just drop all the necessary jars in the EAR/lib folder without having to add them as java modules in application.xml. And the classloader scoping needs to be done here too, if you are overriding some jar files.


            • 3. Re: Ear as a loader repository

              Thanks jaikiran.

              I can't do anything about the version of jboss I am using I am afraid, believe me I would if I could.

              On top of that I am using a build system that packages the EARs up in a specific way, including putting all the jars files in the APP-INF/lib directory. It would be possible for me to configure the build to do it differently, but instead of that I used your suggestion and registered all the jars using:

              <module>
               <java>APP-INF/lib/saaj.jar</java>
              </module>


              Now if I have a jboss-app.xml containing this:

              <jboss-app>
               <loader-repository>
               hello:service=LoaderRepository
               </loader-repository>
              </jboss-app>


              All my jars are loaded from the EAR successfully.

              Thanks again for your help jaikiran, greatly appreciated.