0 Replies Latest reply on Jan 26, 2017 1:53 PM by Sumanth Bandi

    Wildfly Adding jars at AppClassLoader level instead of ModuleClassLoader

    Sumanth Bandi Newbie

      We are moving our application from JBoss 4 to Wildfly 9. Application was working fine in JBoss since all vendor jars were added in the classpath (using -classpath in run.sh).

      In Wildfly, i have added all those jars in one of the module and made application dependent on it. It is working fine except one scenario where classpath is determined in the vendor jars with the following code (which i can't change)

      public static List<String> extractClasspath(final ClassLoader cl, final List<String> cp)


              if (cl instanceof URLClassLoader) {

                       final URL[] urls = ((URLClassLoader) cl).getURLs();

                       for (int i = urls.length - 1; i >= 0; i--) {

                                cp.add(0, urls[i].getFile());


              } else {

                       extractClasspath(cl.getParent(), cp);


              return cp;



      It was working fine in JBoss since all jars are available at AppClassLoader level which is instanceOf URLClassLoader.

      But in Wildfly, all jars are available at ModuleClassLoader level which is not instanceOf URLClassLoader. So it is going to its parent AppClassLoader but these jars are not available at AppClassLoader. So classpath is returning only "wildfly-9.0.2.Final/jboss-modules.jar:" and application is failing.

      The only option i got is to make these jars available at AppClassLoader level like in JBoss. I tried to add these jars through classpath in standalone.conf but server is failing with the following exception:

      Exception in thread "main" java.lang.ClassNotFoundException: org.jboss.as.standalone from [Module "Classpath:main" from Class path module loader for path '/opt/apps/MerckContivoPilot/wildfly-9.0.2.Final/modules/system/layers/base/com/liaison/jars/main']

              at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:205)

              at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:455)

              at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:404)

              at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:385)

              at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:130)

              at java.lang.Class.forName0(Native Method)

              at java.lang.Class.forName(Class.java:348)

              at org.jboss.modules.Module.run(Module.java:296)

              at org.jboss.modules.Main.main(Main.java:487)


      Please help me to resolve this issue. Thank you in advance.