3 Replies Latest reply on May 21, 2003 10:44 AM by patrick.joehri

    Dynamically Loading Classes......

    Mike Newbie

      I am trying to load classes from a specified 'Hot Drop' directory with the following code..

      // Convert the file object to a URL
      URL url = getMyDir().toURL();
      urls = new URL[]{url};

      // Create a new class loader with the directory
      this.classLoader = new URLClassLoader(urls,Thread.currentThread().getContextClassLoader());

      When loading classes that refer to other objects that are deployed in the .war or .jar files I continually get 'ClassNotFoundException'. The ClassLoader that I am using is taking the current threads ClassLoader as a parent parameter. Should this not give the URLClassLoader visibility to the objects loaded by the appServer via the delegation model? If I place the dependent classes in the hot drop directory it expectantly it works. How do I get around this?

        • 2. Re: Dynamically Loading Classes......
          patrick.joehri Newbie

          Hi
          I can not ensure it for jboss, but it works like this for bea weblogic:
          You have to include all classes, jars in the startup path, that are referenced (used) by your dynamical classes. This means you loose all the hot deploying capabilities, but at least you can use your existing classes from your dynamical created or newly delivered ones.
          There are some whitepapers around on bea that try to explain which class loaders are whe used (but this is more the problem when you have EJBs trying to access utility/helper classes outside of your EJBs.
          Hope it helps.
          Regards Patrick

          • 3. Re: Dynamically Loading Classes......
            patrick.joehri Newbie

            Hi
            I can not ensure it for jboss, but it works like this for bea weblogic:
            You have to include all classes, jars in the startup path, that are referenced (used) by your dynamical classes. This means you loose all the hot deploying capabilities, but at least you can use your existing classes from your dynamical created or newly delivered ones.
            There are some whitepapers around on bea that try to explain which class loaders are whe used (but this is more the problem when you have EJBs trying to access utility/helper classes outside of your EJBs.
            Hope it helps.
            Regards Patrick