Getting below exception while running my application :
I am using jboss : 5.1.1 and jdk 1.6.
01:50:04,828 ERROR [[HelloWorld]] Servlet.service() for
Try to switch class loaders.
Grab classloader from your Service class and reset after the call.
final ClassLoader targetClassLoader = ServiceXY.class.getClassLoader();
final Thread currentThread = Thread.currentThread();
final ClassLoader contextClassLoader = currentThread.getContextClassLoader();
try {
currentThread.setContextClassLoader(targetClassLoader);
//here call your Service
} finally {
currentThread.setContextClassLoader(contextClassLoader);
}
JEE libs have been removed with Java 9, JEE-specific libs / implementations must now be made available by the application via thirdparty libraries - e.g. jaxws-api.jar and jaxws-rt.jar. This code of JEE libs often still expects to be part of the jre system library and with that of the application classloader - but it isn't anymore. So if service classloader ServiceXY.class.getClassLoader()
and your application classloader Thread.currentThread().getContextClassLoader()
are different you need to switch for the request.