2 Replies Latest reply on Feb 9, 2006 2:27 AM by Blaise Gosselin

    How to share classes through wars with isolated ClassLoader

    Blaise Gosselin Newbie

      Hello,

      I have two web applications deployed on JBoss 4.0.1SP1 with the following container configuration in jboss-web.xml file :

      <class-loading java2ClassLoadingCompliance="true">
       <loader-repository>
       c-w.com:loader=cwsoft-cwx1
       <looader-repository-config>
       java2ParentDelegation=true
       </looader-repository-config>
       </loader-repository>
      </class-loading>
      

      These webapps share classes through their session.
      So, I put these classes in a common package put in the lib directory of my jboss server configuration.
      But I have a ClassNotFoundException that occured, as if the ClassLoader of my webapp can't have access to the parent ClassLoader, although I set the paremeter java2ClassLoadingCompliance to true.

      Could someone help me please ?

      Thanks in advance.
      _____________________ _ _ _
      bgOnline

        • 1. Re: How to share classes through wars with isolated ClassLoa
          Tyler Black Newbie

          A couple of thoughts...

          Are you sure that you do not have a copy of your shared classes still packaged somewhere in your .war? Have a look at use-case #4 here

          http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossClassLoadingUseCases

          in regards to the HierarchialLoaderRepository class loader's precedence over the parent. The class is not loaded into the repositorie's cache until it is requested, and if it is deployed somewhere in your .war, and your .war is the first thing to request that class, the scoped version of that class will be returned.

          So both of your .war's will have their own versions of the class, cached in their own repositories, which will be siblings of each other, which will cause the ClassCastException.

          As an aside, are there other classes that you want to be isolated between these two .war's? It may be a silly question, but it's a little funny for me to see java2ClassLoadingCompliance set to true, then have a loader-repository configured as well.

          • 2. Re: How to share classes through wars with isolated ClassLoa
            Blaise Gosselin Newbie

            Hi Tyler,

            Thank you for your answer.

            Yes, I'm sure that I don't have a copy of my shared classes. If it was the case, I would have a ClassCastException, but I have a ClassNotFoundException.

            And you are true, the parameter java2ClassLoadingCompliance doesn't change anything if my configuration.

            Thank you...