3 Replies Latest reply on Apr 2, 2002 12:29 PM by Ken

    ClassLoader looking in EJB JAR and not WAR

    Aaron Smith Newbie

      I have a factory class that tries to instantiate a class from my WAR file, but a

      is thrown instead. If I also add the class to the EJB JAR file that is deployed in the same EAR, the class can be found and the app works.

      It seems to me that the problem is the ClassLoader using a different ClassPath. I've tested the code in JBoss 2.3 and 2.4 and the reference implementation from Sun (1.3), and the only positive news is it's consistent :) Any ideas?


        • 1. Re: ClassLoader looking in EJB JAR and not WAR
          Artur Bialecki Newbie

          I have the same problem using 2.4.4 with catalina 4.0.1.
          Is there a solution ?


          • 2. Re: ClassLoader looking in EJB JAR and not WAR
            Jules Gosnell Novice

            Jetty or Tomcat ?


            • 3. Re: ClassLoader looking in EJB JAR and not WAR
              Ken Newbie

              Think of the EAR classloader(s) as a triangle that can only look up. At the top is your library files referenced by the EJB's manifest.mf classpath (if needed) - these are the "utility" or "helper" classes, and are common to both the EJB's and the Web application. The bottom left of the triangle is the EJB class loader, and if memory serves me correctly, the interfaces are exported up to the top of the triangle, so both EJB's and Web Apps can find the classes. The bottom right of the triangle is the Web App - this is where the classes or library files from the WEB-INF directory get exported. If the factory is in the EJB, it has no visibility into the WEB area. If you want the factory to instance another class, the factory must be in the same, or lower class loader than the instanced class. Thus if the factory is in the utility or EJB area, it will not have visibility down into the WEB area. Hope this helps a little ...