2 Replies Latest reply on Nov 6, 2002 9:09 PM by Michael Schoning

    Jetty / Jboss class loader question

    Rodney Moore Newbie

      Using Jboss-3.0.3
      on Windows XP - JDK 1.4

      I have mutiple web applications that use a jar called common.jar deployed in JBOSS/server/default/lib

      common.jar contains a class that tries to instantiate view or action classes defined in each web application.

      I am consistently getting class not found exceptions.

      I imagine putting the common.jar in each web application's lib directoy would solve the problem, but it kind of defeats the purpose of common.jar and a single point of management.

        • 1. Re: Jetty / Jboss class loader question
          Julian Gosnell Expert

          It sounds very much as if, when loading classes, your common.jar is trying to load them with the wrong classloader.

          The J2EE spec expects them to be loaded using Thread.currentThread().getContextClassLoader(). This will have been bound at the beginning of the request to the classloader which knows about your WEB-INF/lib,classes etc...

          Instead your common.jar is most likely just using Class.forName() which will load into the classloader which loaded the common.jar.

          This classloader will only be able to find it's own and it's parents classes - hence it cannot find any of those in your webapp.

          If common.jar is yours, fix the classloading - you should use the Class.forName() which takes 3 params. The third being the target ClassLoader.

          If common.jar is not yours, shout at the people who provided it to you and try copying it into each war. This may cause problems due to loading of multiple copies of the same class, but you may be OK - depends on many variables. Suck it and see


          • 2. Re: Jetty / Jboss class loader question
            Michael Schoning Newbie

            I have had some classloader issues. This link helped me solve my problems
            http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=forums/ default behaviour of JBoss is to use one classloader repository that is common for all applications. So I think you will have to like me and define a repository for each application.