1 Reply Latest reply on Jun 2, 2003 3:12 AM by frito

    Problems using URLClassLoader in JBoss

    omilian

      Hi Folks,

      we need to dynamically load classes. All dynamically loaded classes implement a single specified interface. In my IDE (not running jboss at all) I've had no problem using the URLClassLoader to load classes from various areas on the file system. Once loaded - using loadClass(String) - i can cast a new instance to the interface.

      In jboss i'm using a servlet to invoke a session bean. The servlet does nothing else besides findind and invoking the bean. The bean then uses URLClassLoader in the same way as my example code. Everthing is fine untill the point of casting the new instance to the interface at which point i get a ClassCastException.

      I've read the class loading architecture stuff in the FAQ's and searched the forum but don't seem to see anything to help me. Should I be passing some specific ClassLoader to the load class method? Is there something about class loading in jboss which would effect this?

        • 1. Re: Problems using URLClassLoader in JBoss
          frito

          You have probably deployed the same resource twice (e.g. in your .war with the servlet and with some beans). Therefore it is loaded by two different classloaders leading to this exception.

          One of some possibilities: deploy the shared resources once on toplevel (for your beans and for your .war).

          Greetings,
          Frito