Skip to content

JMS client is not working when initial context factory is loaded using JCL class loader #60

@sandrosimas

Description

@sandrosimas

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions