Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling an EJB from another EJB

Status
Not open for further replies.

db2sachin

Programmer
Jun 9, 2003
24
0
0
AU
I want to call an EJB from another EJB. Both the EJBs are in different WebSphere Application Server.
Basically I have a project running on one server & I want to interact with another project on a different Server. How do I do it without taking the JAR file of the other project ? I just want to lookup the other EJB & then make a call on it. But I don't know how do I map the value objects & signature without having the JAR file of other project.
I hope I'm making my point clear. Pls suggest.
Thanks in advamce.
 
You will need to call the remote ejb object, as you would any other - by setting up a Context :

Code:
            Properties p = new Properties();
            p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
            p.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
            p.put(Context.PROVIDER_URL, "localhost:1099");
            javax.naming.Context ctx = new javax.naming.InitialContext(p);

and then utilising EJB's built in RMI protocol to serialize the required remote object :

Code:
         Object ref = ctx.lookup("MyHomeRemote");
         MyHomeRemote home = (CabinHomeRemote) PortableRemoteObject.narrow(ref,MyHomeRemote.class);   
         MyRemote ejb1 = home.create();
 
Thanks sedj.
I tried what u had told and I guess now its going bit further than it was before. But its giving me following error now-


java.rmi.RemoteException: CORBA NO_RESPONSE 0x4942fb01 Maybe; nested exception is:
org.omg.CORBA.NO_RESPONSE: Response timed out minor code: 4942FB01 completed: Maybe
org.omg.CORBA.NO_RESPONSE: Response timed out minor code: 4942FB01 completed: Maybe
at com.ibm.rmi.iiop.Connection.send(Connection.java:1492)
at com.ibm.rmi.iiop.ClientRequestImpl.invoke(ClientRequestImpl.java:214)
at com.ibm.CORBA.iiop.ClientDelegate.invoke(ClientDelegate.java:517)
at com.ibm.CORBA.iiop.ClientDelegate.invoke(ClientDelegate.java:713)
at org.omg.CORBA.portable.ObjectImpl._invoke(ObjectImpl.java:258)

pls suggest.
Basically I'm trying to call an EJB on another server while my application is running on some other server. But both the servers are IBM Web Sphere.
 
You basically need to make sure that JNDI is properly configured on both servers. You need to make sure that the server names and the ports are that your pass to the jndi conext are correct. If not, your server applications won't be able to look up the ejbs from each other.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top