Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sandrocsimas opened this issue Nov 27, 2017 · 0 comments

Comments

@sandrocsimas
Copy link

sandrocsimas commented Nov 27, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant