Search code examples
jbossjboss7.xwildflyjboss6.xwildfly-8

How to get entire classpath of the modules added to wildfly server


I have tried below snippet

String path = System.getProperty("java.class.path");

I get

../wildfly-8.2.0.Final/jboss-modules.jar

 String modulepath = System.getProperty("jboss.module.path");
// ../wildfly-8.2.0.Final/jboss-modules.jar

and not the ones which i have added in modules

when i try

StringBuffer buffer = new StringBuffer();
for (URL url :
    ((URLClassLoader) (Thread.currentThread()
    .getContextClassLoader())).getURLs()) {
    buffer.append(new File(url.getPath()));
    buffer.append(System.getProperty("path.separator"));
            }

Getting :

java.lang.ClassCastException: org.jboss.modules.ModuleClassLoader cannot be cast to java.net.URLClassLoader


Solution

  • Use getResourceAsStream on your application class path which is using the same class loader as your app.