Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
1 reply Latest Post - ‏2011-06-07T05:42:22Z by Kart_G
SystemAdmin
SystemAdmin
2340 Posts
ACCEPTED ANSWER

Pinned topic NoInitialContextException when client connecting to Websphere

‏2010-12-23T08:34:13Z |
Hello,
I am following this sample program http://publib.boulder.ibm.com/infocenter/wxsinfo/v7r1/index.jsp?topic=/com.ibm.websphere.extremescale.admin.doc/txsmbeanprog.html to connect to MBean server in Websphere

My client is a simple console application with code as below, this is run on the WAS server itself

String serviceURL = "service:jmx:iiop://" + hostname + ":" + port + "/jndi/JMXConnector";
JMXServiceURL jmxUrl = new JMXServiceURL(serviceURL);

Hashtable<String, Object> h = new Hashtable<String, Object>();
String providerUrl = "corbaloc:iiop:" + hostname + ":" + port + "/WsnAdminNameService";
h.put(Context.PROVIDER_URL, providerUrl);
h.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
JMXConnector jmxCon = JMXConnectorFactory.connect(jmxUrl,h);

java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.NoInitialContextException: Failed to create InitialContext using factory specified in hashtable {java.naming.provider.url=corbaloc:iiop:localhost:10103/WsnAdminNameService, java.nam
ing.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactory, java.naming.corba.orb=com.ibm.CORBA.iiop.ORB@3ece3ece, jmx.remote.credentials=[Ljava.lang.String;@51685168} http://Root exception is java.lang.NullPointerException
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:334)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:259)
at com.visa.remoteclientapp.RemoteClientApp.init(RemoteClientApp.java:83)
at com.visa.remoteclientapp.RemoteClientApp.main(RemoteClientApp.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:599)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)
Caused by: javax.naming.NoInitialContextException: Failed to create InitialContext using factory specified in hashtable {java.naming.provider.url=corbaloc:iiop:localhost:10103/WsnAdminNameService, java.naming.factory.initial=com.ibm.websphere.naming.
WsnInitialContextFactory, java.naming.corba.orb=com.ibm.CORBA.iiop.ORB@3ece3ece, jmx.remote.credentials=[Ljava.lang.String;@51685168} http://Root exception is java.lang.NullPointerException
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:246)
at javax.naming.InitialContext.initializeDefaultInitCtx(InitialContext.java:327)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:357)
at javax.naming.InitialContext.internalInit(InitialContext.java:295)
at javax.naming.InitialContext.<init>(InitialContext.java:212)
at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1880)
at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1852)
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:268)
... 8 more
Caused by: java.lang.NullPointerException
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:238)

The orb trace says..

19:29:58.901 com.ibm.rmi.pi.InterceptorManager runPreInit:178 P=198711:O=0:CT ORBRasdefault java.lang.ClassNotFoundException: com.ibm.ISecurityLocalObjectBaseL13Impl.CSIClientRI
at com.ibm.CORBA.iiop.UtilDelegateImpl.loadClass(UtilDelegateImpl.java:663)
at javax.rmi.CORBA.Util.loadClass(Util.java:252)
at com.ibm.rmi.pi.InterceptorManager.runPreInit(InterceptorManager.java:172)
at com.ibm.rmi.corba.ORB.initializeInterceptors(ORB.java:627)
at com.ibm.CORBA.iiop.ORB.initializeInterceptors(ORB.java:1075)
at com.ibm.rmi.corba.ORB.orbParameters(ORB.java:1322)
at com.ibm.rmi.corba.ORB.set_parameters(ORB.java:1234)
at com.ibm.CORBA.iiop.ORB.set_parameters(ORB.java:1686)
at org.omg.CORBA.ORB.init(ORB.java:364)
at javax.management.remote.rmi.RMIConnector.resolveOrb(RMIConnector.java:1717)
at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1847)
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:268)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:259)
at com.visa.remoteclientapp.RemoteClientApp.init(RemoteClientApp.java:83)
at com.visa.remoteclientapp.RemoteClientApp.main(RemoteClientApp.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:599)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)

19:29:58.905 com.ibm.rmi.pi.InterceptorManager runPreInit:178 P=198711:O=0:CT ORBRasdefault java.lang.ClassNotFoundException: com.ibm.ejs.ras.RasContextSupport
at com.ibm.CORBA.iiop.UtilDelegateImpl.loadClass(UtilDelegateImpl.java:663)
at javax.rmi.CORBA.Util.loadClass(Util.java:252)
at com.ibm.rmi.pi.InterceptorManager.runPreInit(InterceptorManager.java:172)
at com.ibm.rmi.corba.ORB.initializeInterceptors(ORB.java:627)
at com.ibm.CORBA.iiop.ORB.initializeInterceptors(ORB.java:1075)
at com.ibm.rmi.corba.ORB.orbParameters(ORB.java:1322)
at com.ibm.rmi.corba.ORB.set_parameters(ORB.java:1234)
at com.ibm.CORBA.iiop.ORB.set_parameters(ORB.java:1686)
at org.omg.CORBA.ORB.init(ORB.java:364)
at javax.management.remote.rmi.RMIConnector.resolveOrb(RMIConnector.java:1717)
at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1847)
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:268)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:259)
at com.visa.remoteclientapp.RemoteClientApp.init(RemoteClientApp.java:83)
at com.visa.remoteclientapp.RemoteClientApp.main(RemoteClientApp.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:599)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)

19:29:58.908 com.ibm.rmi.pi.InterceptorManager runPreInit:178 P=198711:O=0:CT ORBRasdefault java.lang.ClassNotFoundException: com.ibm.ISecurityLocalObjectBaseL13Impl.ClientRIWrapper
at com.ibm.CORBA.iiop.UtilDelegateImpl.loadClass(UtilDelegateImpl.java:663)
at javax.rmi.CORBA.Util.loadClass(Util.java:252)
at com.ibm.rmi.pi.InterceptorManager.runPreInit(InterceptorManager.java:172)
at com.ibm.rmi.corba.ORB.initializeInterceptors(ORB.java:627)
at com.ibm.CORBA.iiop.ORB.initializeInterceptors(ORB.java:1075)
at com.ibm.rmi.corba.ORB.orbParameters(ORB.java:1322)
at com.ibm.rmi.corba.ORB.set_parameters(ORB.java:1234)
at com.ibm.CORBA.iiop.ORB.set_parameters(ORB.java:1686)
at org.omg.CORBA.ORB.init(ORB.java:364)
at javax.management.remote.rmi.RMIConnector.resolveOrb(RMIConnector.java:1717)
at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1847)
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:268)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:259)
at com.visa.remoteclientapp.RemoteClientApp.init(RemoteClientApp.java:83)
at com.visa.remoteclientapp.RemoteClientApp.main(RemoteClientApp.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:599)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)

19:29:58.911 com.ibm.rmi.pi.InterceptorManager runPreInit:178 P=198711:O=0:CT ORBRasdefault java.lang.ClassNotFoundException: com.ibm.ws.activity.remote.cos.ActivityServiceClientInterceptor
at com.ibm.CORBA.iiop.UtilDelegateImpl.loadClass(UtilDelegateImpl.java:663)
at javax.rmi.CORBA.Util.loadClass(Util.java:252)
at com.ibm.rmi.pi.InterceptorManager.runPreInit(InterceptorManager.java:172)
at com.ibm.rmi.corba.ORB.initializeInterceptors(ORB.java:627)
at com.ibm.CORBA.iiop.ORB.initializeInterceptors(ORB.java:1075)
at com.ibm.rmi.corba.ORB.orbParameters(ORB.java:1322)
at com.ibm.rmi.corba.ORB.set_parameters(ORB.java:1234)
at com.ibm.CORBA.iiop.ORB.set_parameters(ORB.java:1686)
at org.omg.CORBA.ORB.init(ORB.java:364)
at javax.management.remote.rmi.RMIConnector.resolveOrb(RMIConnector.java:1717)
at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1847)
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:268)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:259)
at com.visa.remoteclientapp.RemoteClientApp.init(RemoteClientApp.java:83)
at com.visa.remoteclientapp.RemoteClientApp.main(RemoteClientApp.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:599)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)

19:29:58.913 com.ibm.rmi.pi.InterceptorManager runPreInit:178 P=198711:O=0:CT ORBRasdefault java.lang.ClassNotFoundException: com.ibm.ws.wlm.client.WLMClientInitializer
at com.ibm.CORBA.iiop.UtilDelegateImpl.loadClass(UtilDelegateImpl.java:663)
at javax.rmi.CORBA.Util.loadClass(Util.java:252)
at com.ibm.rmi.pi.InterceptorManager.runPreInit(InterceptorManager.java:172)
at com.ibm.rmi.corba.ORB.initializeInterceptors(ORB.java:627)
at com.ibm.CORBA.iiop.ORB.initializeInterceptors(ORB.java:1075)
at com.ibm.rmi.corba.ORB.orbParameters(ORB.java:1322)
at com.ibm.rmi.corba.ORB.set_parameters(ORB.java:1234)
at com.ibm.CORBA.iiop.ORB.set_parameters(ORB.java:1686)
at org.omg.CORBA.ORB.init(ORB.java:364)
at javax.management.remote.rmi.RMIConnector.resolveOrb(RMIConnector.java:1717)
at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1847)
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:268)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:259)
at com.visa.remoteclientapp.RemoteClientApp.init(RemoteClientApp.java:83)
at com.visa.remoteclientapp.RemoteClientApp.main(RemoteClientApp.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:599)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)

19:29:58.923 com.ibm.rmi.pi.InterceptorManager runPreInit:178 P=198711:O=0:CT ORBRasdefault java.lang.ClassNotFoundException: com.ibm.ws.Transaction.JTS.TxInterceptorInitializer
at com.ibm.CORBA.iiop.UtilDelegateImpl.loadClass(UtilDelegateImpl.java:663)
at javax.rmi.CORBA.Util.loadClass(Util.java:252)
at com.ibm.rmi.pi.InterceptorManager.runPreInit(InterceptorManager.java:172)
at com.ibm.rmi.corba.ORB.initializeInterceptors(ORB.java:627)
at com.ibm.CORBA.iiop.ORB.initializeInterceptors(ORB.java:1075)
at com.ibm.rmi.corba.ORB.orbParameters(ORB.java:1322)
at com.ibm.rmi.corba.ORB.set_parameters(ORB.java:1234)
at com.ibm.CORBA.iiop.ORB.set_parameters(ORB.java:1686)
at org.omg.CORBA.ORB.init(ORB.java:364)
at javax.management.remote.rmi.RMIConnector.resolveOrb(RMIConnector.java:1717)
at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1847)
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:268)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:259)
at com.visa.remoteclientapp.RemoteClientApp.init(RemoteClientApp.java:83)
at com.visa.remoteclientapp.RemoteClientApp.main(RemoteClientApp.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:599)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)

19:29:58.926 com.ibm.rmi.pi.InterceptorManager runPreInit:178 P=198711:O=0:CT ORBRasdefault java.lang.ClassNotFoundException: com.ibm.debug.olt.ivbtrjrt.OLT_RI
at com.ibm.CORBA.iiop.UtilDelegateImpl.loadClass(UtilDelegateImpl.java:663)
at javax.rmi.CORBA.Util.loadClass(Util.java:252)
at com.ibm.rmi.pi.InterceptorManager.runPreInit(InterceptorManager.java:172)
at com.ibm.rmi.corba.ORB.initializeInterceptors(ORB.java:627)
at com.ibm.CORBA.iiop.ORB.initializeInterceptors(ORB.java:1075)
at com.ibm.rmi.corba.ORB.orbParameters(ORB.java:1322)
at com.ibm.rmi.corba.ORB.set_parameters(ORB.java:1234)
at com.ibm.CORBA.iiop.ORB.set_parameters(ORB.java:1686)
at org.omg.CORBA.ORB.init(ORB.java:364)
at javax.management.remote.rmi.RMIConnector.resolveOrb(RMIConnector.java:1717)
at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1847)
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:268)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:259)
at com.visa.remoteclientapp.RemoteClientApp.init(RemoteClientApp.java:83)
at com.visa.remoteclientapp.RemoteClientApp.main(RemoteClientApp.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:599)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)
On further digging, i realised that the WAS related environment variables are not set, even when I run setupCmdLine.sh .
I am runing my client from the console on WAS server. Why would the enviroment variables be not available?

Please help.
Updated on 2011-06-07T05:42:22Z at 2011-06-07T05:42:22Z by Kart_G
  • Kart_G
    Kart_G
    1 Post
    ACCEPTED ANSWER

    Re: NoInitialContextException when client connecting to Websphere

    ‏2011-06-07T05:42:22Z  in response to SystemAdmin
    Okay, even I had this problem. You need to add a WAS jar file at run time. Try adding this jar file :
    <WAS_HOME>\AppServer\runtimes\com.ibm.ws.admin.client_7.0.0.jar

    All the best!