4

I am tring to lookup the resource defined on the Websphere aplication server 7.0 from the out side of the Container with using the iiop protocol as 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 to call the 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 runnig the client on my local machin and bootstrap host is : localhost and the port is 2809.

At the time of running the Test.jar code form the command file I am getting 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:357)
    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 have no idea that why this code is not able to instantiat the InitialContext(Hashmap env). This same code is running in Websphere application server version 5.1 but having problem in Websphere application server version 7.0.

skaffman
  • 398,947
  • 96
  • 818
  • 769

1 Answers1

2

Using JARs from WAS_HOME/deploytool for the classpath is not supported. Try using the documented EJB thinclient with WAS_HOME/runtimes/com.ibm.ws.ejb.thinclient_7.0.0.jar.

Brett Kail
  • 33,593
  • 2
  • 85
  • 90
  • Where can I find IIOP port and hostname? somewhere on WAS8 Admin console? – Govinda Sakhare Jul 29 '19 at 18:10
  • @GovindaSakhare Presumably, yes, but I have not used WAS in several years. If you can't find it, I recommend starting a new question rather than commenting on a 7-year-old answer. – Brett Kail Jul 29 '19 at 20:36