2 Replies Latest reply on May 13, 2013 3:10 AM by Kylin Soong

    How Modular ClassLoader Framework Module load external libraries?

    Kylin Soong Novice

      Issue Depiction

      I have a Module, which it need to lookup JNDI service from JBoss, so we need add JNDI client libraries(JBOSS_HOME/client) to class path, in traditional class loading mechanism we can use URLClassLoader like below:

       

      MyURLClassLoader classLoader = new MyURLClassLoader(Thread.currentThread().getContextClassLoader());
      classLoader.loadDependencyJars(clientPath);
      Thread.currentThread().setContextClassLoader(classLoader);
      
      public class MyURLClassLoader extends URLClassLoader { 
      
           public MyURLClassLoader(ClassLoader parent) {
              super(new URL[] { }, parent);
          }
      
         ....
      }
      

       

      But when use Modular ClassLoader Framework, it doesn't work. Completed java code can be found below:

       

          CST06Reproduction

          MyURLClassLoader

       

      How to Reproduce

      • Dowload reproduction.zip unzip, CustomizedTools folder will generated
      • Start JBoss Server(either JBoss EAP 5.x, JBoss AS 5.x, or JBoss AS 6.x)
      • Came to CustomizedTools/bin folder, run cst06.sh, this will use Modular ClassLoader Framework, as below:

       

      ./cst06.sh <JBOSS_HOME/client>
      
      • Came to CustomizedTools folder, Use traditional class loader mechanism run, as below:

       

      java -cp modules/com/customized/tools/test/main/cst-test.jar:modules/javax/jms/main/jms-api-1.1-rev-1.jar com.customized.tools.test.cst06.CST06Reproduction <JBOSS_HOME/client>
      
      • Use Modular ClassLoader Framework failed with Exception throws, use traditional class loader run successful with jndi lookup successful output

       

      My Question:


         How to load external libraries via ModularClassLoader?

       

      Message was edited by: Kylin Soong

       

      Message was edited by: Kylin Soong