2 Replies Latest reply on Apr 13, 2010 3:19 AM by Stéphane Mangeot

    JBoss AS 5.0.1 GA, classloading, ear and wars.

    Stéphane Mangeot Newbie

      Hi,

       

      We are facing a classloading problem, here is the description :

      - We have 2 wars in an ear

      - We have the Foo class in a common jar at the root of the ear

      - Each war uses a cache JBossCache which is a static instance of org.jboss.cache.Cache packaged in a jar file under the ear

      - The 2 wars are referencing the common lib via the manifest file

       

      What happends ?

      1) war1 puts the pojo Foo in the cache

      2) war2 gets the pojo From from the cache => ClassCastException

       

      We have seen that the classloader used to find the Foo class was the war's classloader and not the ear's.

       

      We only want to configure our application to do that :

      - if a war doesn't find a class with its own classloader, he delegates the search to its parent classloader which must be the ear's

      - we don't want to isolate wars because we want a sigle instance of the cache

       

      Thanks for your help,

       

      Stéphane.

        • 1. Re: JBoss AS 5.0.1 GA, classloading, ear and wars.
          jaikiran pai Master

          Are you sure, the Foo class is not present in more than one jar files? Also, place the common.jar in .ear/lib folder instead of the root of the ear. The jars in the .ear/lib folder are available to all the components in the .ear (including those 2 war files). And finally, I would recommend that you use the latest AS 5.1.0 instead of 5.0.1.

          • 2. Re: JBoss AS 5.0.1 GA, classloading, ear and wars.
            Stéphane Mangeot Newbie

            Thanks for your quick response.

             

            jaikiran pai a écrit:

             

            Are you sure, the Foo class is not present in more than one jar files?

             

            Yes, we have verified this by calling  getProtectionDomain().getCodeSource() on the Foo class from the 2 wars and the same jar file was returned.

            jaikiran pai a écrit:

             

            Also, place the common.jar in .ear/lib folder instead of the root of the ear. The jars in the .ear/lib folder are available to all the components in the .ear (including those 2 war files).

             

            We'll try this today.

            jaikiran pai a écrit:

             

            And finally, I would recommend that you use the latest AS 5.1.0 instead of 5.0.1.

             

            I agree with you but our hosting partner not .

             

            Thanks, I keep you wired.

             

            Stéphane.