ejb@glassfish.java.net

Re: EJB FAQ

From: Chase <chase_at_osdev.org>
Date: Thu, 04 May 2006 12:16:16 -0500

Paul,

First of all the whole idea of a JNDI global context isn't part of the
standard, just something everyone does. I think the spec does say
something to the effect of - If you ever declare a reference to a local
session bean(with xml descriptors or @EJB notations) then there will be
a JNDI name in java:comp:/env to that bean for the module that declared
the reference. The enc JNDI name is based on the package and class
name(see section 15.5.1 of the EJB spec)

Given that in EJB3 you try to avoid xml descriptors that means you'll be
using @EJB notations. The problem is that you can't use the notations in
non-managed classes, such as a POJO business delegate type class. To
enable JNDI look ups in the POJO class you have to put a @EJB notation
somewhere you don't need it or keep making xml descriptors.

If local session beans had default JNDI names life would be easier(just
a little less portable).....
https://glassfish.dev.java.net/issues/show_bug.cgi?id=577


You should be able to use @EJB notations for EJB 2.1 beans, just make
the reference type be the home interface and *not* the EJBObject
interface. I haven't done it but the spec says you can.


-Chase

Pavel Rábek wrote:
> Hello,
> I'm sending two follow-up questions for EJB FAQ.
>
> My first question concerning Local EJB Access:
> I'm able to get reference to Local interface of session bean through @EJB injection.
> But what about if I want to get this reference in run-time? (I mean some kind of lookup).
> Lookup doesn't work as I tried and read in EJB FAQ: "global JNDI names only apply
> to Session/Entity beans that have some kind of Remote interface"
>
> My second question concerns EJB2 lookup:
> How can I use @EJB annotation to inject EJB2 session bean?
> I'm able to lookup EJB2 bean via old style lookup but not via @EJB...
>
> Thanks,
> Paul
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ejb-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: ejb-help_at_glassfish.dev.java.net
>
>