Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connect Client to EJB ???

 
Bill Dao
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"XI_TRUM",
Your display name doesn't comply with our naming policy as it is, so you'll need to change it (both first and last name required, no underscore in between ).
Thanks, and welcome to the JavaRanch!
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah. I almost forgot... This question is really better suited for our IBM/WebSphere forum so I'll ask someone to move it there.
 
Bill Dao
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK. Thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic