Hi,
We are upgrading JBoss 4.3 to JBoss AS 7 and facing this issue i.e. Thread.currentThread().getContextClassLoader().getResource("../lib/") returning null while loading resources.
In JBoss 4.3 Thread.currentThread().getContextClassLoader().getResource("../lib/") was returning proper URL.
With jboss-eap-6.4 we tried below approaches to load resources using Thread.currentThread().getContextClassLoader() class loader:
- Tried to load resource by providing WEB-INF directory as Thread.currentThread().getContextClassLoader().getResource("WEB-INF"); but it also return null;
- Tried to load file hibernate.cfg.xml (this file is placed under WEB-INF/classes) as Thread.currentThread().getContextClassLoader().getResource("hibernate.cfg.xml "); file loaded and can get file path as well.
- Tried to load any property file like abcd. properties file (this file is placed under WEB-INF/lib folder) as Thread.currentThread().getContextClassLoader().getResource("abcd. properties "); but it also return null.
- We also tried to load the current directory by Thread.currentThread().getContextClassLoader().getResource("/") it is pointing to $EAP_HOMNE/modules/sun/jdk/main/service-loader-resources/
As per our understanding it is happing because of class loader change in JBoss AS 7. In JBoss 4.3 WebappClassLoader was used and it was loading resources from ../lib directory properly but in JBoss AS 7 class loader changed to ModuleClassLoader due to this resource loading behavior got changed.
So we have below few queries pls provide:
- Is there any alternate way load resources from WEB-INF/lib directory?
- Is there any alternate way load resources from WE-INF directory?
- Is there any way to load resources from *.war directory?
Thanks,
Brajendra