I am trying to find the resource defined on the Websphere 7.0 assembler server from the outside of the container using the iiop protocol as shown below:
Java Code for (RMI Client) Test.jar:
public static void main(String[] args){ Hashtable<Object, Object> properties = new Hashtable<Object, Object>(); properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory"); properties.put(Context.PROVIDER_URL, "iiop://localhost:2809"); InitialContext intCt; try { InitialContext initCtx = new InitialContext(properties); Object obj = intCt.lookup(JNDI_NAME); }catch (NamingException namingE) { System.out.println("Naming Exception occurred :"); namingE.printStackTrace(); } }
Cmmand file for calling Test.jar:
set appClassPath = C: \ WebSphere \ AppServer7.0 \ deploytool \ itp \ plugins \ com.ibm.websphere.v7_7.0.1.v20090422_1423 \ wasJars \ naming.jar; C: \ WebSphere \ AppServer7.0 \ deploytool \ itp \ plugins \ com.ibm.websphere.v7_7.0.1.v20090422_1423 \ wasJars \ namingclient.jar; C: \ WebSphere \ AppServer7.0 \ properties; C: \ Batch \ CommandFiles \ JobServer \ Test.jar
C: \ WebSphere \ AppServer7.0 \ java \ jre \ bin \ java -jar -cp "% appClassPath%" C: \ Batch \ CommandFiles \ JobServer \ Test.jar% Parameters%
NOTE. Please, not that I am running on my local computer and boot node: localhost and port 2809.
When running the Test.jar code from the command file, I get the following error:
javax.naming.NoInitialContextException: Failed to create InitialContext using factory specified in hashtable {java.naming.provider.url = iiop: // localhost: 2809, java.naming.factory.initial = com.ibm.websphere.naming.WsnInitialContextFactory} [Root exception is java.lang.NullPointerException]
at javax.naming.spi.NamingManager.getInitialContext (NamingManager.java:243)
at javax.naming.InitialContext.initializeDefaultInitCtx (InitialContext.java:327)
at javax.naming.InitialContext.getDefaultInitCtx (InitialContext.java data57)
at javax.naming.InitialContext.internalInit (InitialContext.java:295)
at javax.naming.InitialContext. (InitialContext.java:212)
at com.uuic.ets.rmi.server.client.Client.main (Client.java:130)
Caused by: java.lang.NullPointerException
at javax.naming.spi.NamingManager.getInitialContext (NamingManager.java:235)
... 5 more
I do not know why this code is not able to implement InitialContext(Hashmap env) . The same code works on Websphere version 5.1 application server, but has problems with WebSphere version 7.0 application server.
Hitarthi
source share