2 Replies Latest reply on Nov 6, 2002 4:58 PM by mschoning

    class loader problem

    mschoning

      I get a ClassNotFoundException when I try to instantiate a class in my application. I have an EAR file containing a war file containing my webappplication.
      In my WEB-INF/lib I have a number of jar files.

      My problem is when a servlet tries to load a class like this:

      Class controllerClass = Class.forName(controllerName);

      The controllerName contains a fully qualified name to a class that exists in my jar files ( I have double checked)

      Using the debugger I have verified that the current classloader has the path to my jar files.

      Is there anyone else that has experienced a problem like this and found a solution? I would not like to load my jar file where the system class loader can find it, as it is application specific classes in them.

      I have run the same code on both Tomcat and Websphere without problem, but not encapsulated in an EAR file so maybe that’s my problem, but at the same time I really would like to package my application in ear files, since I now will add EJB’s to them.

      I am running JBoss 3.0.3 with Jetty on W2K.

      Thanks, Michael

        • 1. Re: class loader problem
          mschoning

          A little update. I have two ear files containing different applications. But both ear files have some common jar files. If I remove my other ear file, it works fine my class loader can load my class using Class.forName.

          Does anyone know how the classloader tree in JBoss looks?

          thanks, Michael

          • 2. Re: class loader problem
            mschoning

            Okay I am having a monologue here, but since I have started I might as well finish. I found this link:
            http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=forums/ basically explains that the different ear files have the same class loader. To get different class loaders for each ear file put a jboss-app.xml in your earfile and an entry like this:
            <jboss-app>
            <loader-
            repository>some.dot.com:loader=webtest.ear</loader-
            repository>
            </jboss-app

            That worked like a charm for me.

            Michael