users@glassfish.java.net

Re: Debug _at_EJB (javax.ejb.EJB) annotation in Web Application

From: <glassfish_at_javadesktop.org>
Date: Mon, 16 Mar 2009 13:47:16 PDT

>
> FWIW the code, in particular the context lookup, I
> posted works as I use it
> every day :-)

Is the target a Remote EJB or a Local EJB? Glassfish V2 (and earlier) does not
register global JNDI names for local EJBs, so a new InitialContext().lookup("MyBean") would never resolve to a Local EJB.

>
> What I left out, as obvious, but perhaps not entirely
> were the details of
> the ejb-local-ref in the web.xml -
>
> <ejb-local-ref>
> <ejb-ref-name>foo/MyBean/local</ejb-ref-name>
> <ejb-ref-type>Session</ejb-ref-type>
> <local>com.MyModel</local>
> <ejb-link>MyBean</ejb-link>
> </ejb-local-ref>
>
> Using the lookup path java:com/env/MyBean actually
> leads to

If the code is trying to resolve this ejb-local-ref declared in web.xml,
the corresponding lookup would be "java:comp/env/foo/MyBean/local".
It's always the @EJB name() / or <ejb-ref-name> portion appended to "java:comp/env/"
that accesses the environment dependency. Note that this is completely different
than doing a global lookup with an unqualified name.

The java:comp/env/ lookup names are standardized. Global names are not. Although, we
are fixing that issue in Java EE 6. See : http://blogs.sun.com/kensaks/entry/portable_global_jndi_names and
http://blogs.sun.com/kensaks/entry/ejb_3_1_proposed_final
[Message sent by forum member 'ksak' (ksak)]

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