• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Connect Client to EJB ???

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK. Thank you.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic