users@glassfish.java.net

Re: cannot lookup Local interface

From: <glassfish_at_javadesktop.org>
Date: Fri, 14 Mar 2008 12:26:54 PST

Hi Stefan,

Remote EJB interfaces have a global lookup string so they can be accessed from another application or a different JVM. Local EJB interfaces are only required to be visible within the same application, so they have never had a global JNDI name assigned to them in our implementation.

You can define an EJB dependency using @EJB and look it up dynamically as well.

@Resource
SessionContext ctx;

@EJB(name="myTestRef")
TestIF test;

...

  // lookup a local EJB dependency called myTestRef in my private component environment
  TestIF test2 = (TestIF) ctx.lookup("myTestRef");

  // an equivalent way using InitialContext.
  TestIF test2 = (TestIF) new InitialContext().lookup("java:comp/env/myTestRef");

You can find more information on these topics in our EJB FAQ :

 https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html

 --ken
[Message sent by forum member 'ksak' (ksak)]

http://forums.java.net/jive/thread.jspa?messageID=264108