I use IBM WebSphere 5.0 for development.
1) In
EJB Modules, I have a SessionBean with simple helloworld method returns
String "HelloWorld"). I deployed and RMIC code.
2) In Application Client Module, I have a
java class with
public static void main(String [] args){
HashTable env = new HashTable();
String result;
try{
env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
env.put(javax.naming.Context.PROVIDER_URL, "iiop://127.0.0.1:2809");
InitialContext initialContext = new InitialContext(env);
Object ref = initialContext.lookup("HelloWorld");
HelloWorldHome home = (HelloWorldHome)
javax.rmi.PortableRemoteObject.narrow
(ref,HelloWorldHome.class);
HelloWorld obj = home.create();
result=obj.helloworld();
System.out.print(result);
}catch (java.rmi.RemoteException re){re.printStackTrace();}
catch (javax.naming.NamingException ne){ne.printStackTrace();}
catch (javax.ejb.CreateException ce){ce.printStackTrace();}
catch (javax.ejb.FinderException fe){fe.printStackTrace();}
}
Then I create a testserver in IBM WSAD 5.0, run EJB on this server and run Application Client in Websphere Client Enviroment. I
test EJB and Client on one computer and console printed "Hello World". But when I run EJB module on first computer only server with IPAdd : 10.4.100.24 and RMI connector at port 2809 , Application Client on second computer. Both of computer installed IBM WSAD 5.0 . With Client code following :
public static void main(String [] args){
HashTable env = new HashTable();
String result;
try{
env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
env.put(javax.naming.Context.PROVIDER_URL, "iiop://10.4.100.24:2809");
InitialContext initialContext = new InitialContext(env);
Object ref = initialContext.lookup("HelloWorld");
HelloWorldHome home = (HelloWorldHome)
javax.rmi.PortableRemoteObject.narrow
(ref,HelloWorldHome.class);
HelloWorld obj = home.create();
result=obj.helloworld();
System.out.print(result);
}catch (java.rmi.RemoteException re){re.printStackTrace();}
catch (javax.naming.NamingException ne){ne.printStackTrace();}
catch (javax.ejb.CreateException ce){ce.printStackTrace();}
catch (javax.ejb.FinderException fe){fe.printStackTrace();}
}
I receive from second computer :
javax.naming.CommunicationException :.........."iiop://10.4.100.24:2809"....
I don't understand. Can you help me ?