ejb@glassfish.java.net

[Fwd: EJB 3.0 Lookup]

From: Michael Munn <Michael.Munn_at_Sun.COM>
Date: Thu, 31 May 2007 13:28:23 -0700

attached mail follows:



Hi All,

In EJB 3.0 to call another session bean on a remote server I use injection:

@EJB(mappedName="corbaname:iiop:192.168.0.2:3700#EJB2") EJB2Remote
ejb2Remote;

If I wanted to make a call to the session bean on the same server
dynamically how would I do it in EJB 3.0

Should this work?

InitialContext ctx = new InitialContext();
EJB2Remote ejb2Remote =
(EJB2Remote)ctx.lookup("corbaname:iiop:192.168.0.2:3700#EJB2");

Using the injection works fine, but I get the following error with the
second approach:

"javax.naming.NameNotFoundException [Root exception is
org.omg.CosNaming.NamingContextPackage.NotFound:
IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]"

What is the correct syntax for explicitly doing a lookup in EJB 3.0?