Jar Class Loader, a configurable and dynamic custom classloader designed to create, manage and manipulate isolated Java classloaders in IoC frameworks and web applications.
I'm trying to implement a JMS client using Weblogic implementation, but its not working correctly.
The inicial context factory class of Weblogic JMS implementation is weblogic.jndi.WLInitialContextFactory.
I was looking at the code and I found the reason it was not working. The class mentioned above is found by JCL, but for some reason, JCL is creating the instance in a different way of the class loader used by JMS, the context class loader.
// JMS is instantiating the initial context factory this way:
loadClass(className, getContextClassLoader())
// The code above call...
Class.forName(className, true, classLoader)
// Getting class loader:
ClassLoader getContextClassLoader() {
return AccessController.doPrivileged(
new PrivilegedAction<ClassLoader>() {
public ClassLoader run() {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
if (loader == null) {
// Don't use bootstrap class loader directly!
loader = ClassLoader.getSystemClassLoader();
}
return loader;
}
}
);
}
Loading the initial context factory class using Thread.currentThread().getContextClassLoader() works fine. Using JCL class loader, the class is instantiated, but for some reason I could not connect to JMS server.
I'm trying to implement a JMS client using Weblogic implementation, but its not working correctly. The inicial context factory class of Weblogic JMS implementation is
weblogic.jndi.WLInitialContextFactory
. I was looking at the code and I found the reason it was not working. The class mentioned above is found by JCL, but for some reason, JCL is creating the instance in a different way of the class loader used by JMS, the context class loader.Loading the initial context factory class using
Thread.currentThread().getContextClassLoader()
works fine. Using JCL class loader, the class is instantiated, but for some reason I could not connect to JMS server.