Initial Context lookup causes ClassNotFoundException: org.jnp.interfaces.NamingContextFactory

Solution Unverified - Updated -

Issue

  • Observing Initial Context lookup issue from MBean code.
  • Created one MBean that registered in mbean server through code and invoking start method from JConsole and the standalone MBean client code contains session bean lookup but while lookup initial context it throws NoInitialContextException. The MBean client code snippet is as following:
     //MBean Register Code
     MBeanServer mbeanServer = MBeanServerLocator.locate();
     mbeanServer.registerMBean(mbeanObj, objName);

     //Session bean lookup code
     Properties p = new Properties( );
     p.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
     p.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
     p.put(Context.PROVIDER_URL, providerUrl);
     InitialContext ic = javax.naming.InitialContext(p)
  • While running the remote Standalone MBean Client code which internally invokes an EJB Deployed on JBoss EAP5 the following exception is observed:
[Thread-23] [TRACE] [ Test_A ] : javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
    at javax.naming.InitialContext.init(InitialContext.java:223)
    at javax.naming.InitialContext.<init>(InitialContext.java:197)
        .
        .
Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:247)
    at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:46)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
  • The same code works when invoking start method of the MBean Client code when it is deployed on the same JBoss instance.

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 5.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content