0
votes

I have a WAR that I have deployed to JBoss 7 that dynamicially loads jar resources using its context class loader.

final ClassLoader cl = Thread.currentThread().getContextClassLoader();
propertiesUrls = cl.getResources(TRANSLATION_PROPERTIES);

However the context classloader only looks for resources in the WEB-INF/lib folder

ModuleClassLoader for Module "deployment..war:main" from Service Module Loader

How do I get hold of a classloader for a specific module in jboss that I have the resources in. I have the jars that i need to load in a custom module in JBOSS_HOME/modules/org/custom/...

1
Do you have a dependency in your WAR on the module you created? - James R. Perkins
Yes i have a jboss-deployment-structure.xml that specifies the module as a dependency bundled in the WEB-INF folder of the war. JBoss container itself seems to figure the classes in the module. Its just that its loaded from a different classloader (modules are loaded in its own classloader in JBoss 7) and I need to get hold of the classloader. The current thread context classloader always is the default war loader but how do i get to the module classloader. - abhishekhp
Nevermind I had to use the current classloader instead of the Thread context classloader. this.getClass().getClassLoader() instead of Thread.currentThread().getContextClassLoader() - abhishekhp
@abhishekhp you could add that as an answer and mark this as answered - eis

1 Answers

0
votes

You need to use the current classloader instead of the Thread context classloader. i.e. this.getClass().getClassLoader() instead of Thread.currentThread().getContextClassLoader()