users@glassfish.java.net

Re: _at_EJB and the name() attribute

From: Laird Nelson <ljnelson_at_gmail.com>
Date: Fri, 2 Aug 2013 06:49:29 -0700

On Thu, Aug 1, 2013 at 9:04 PM, Marina Vatkina <marina.vatkina_at_oracle.com>wrote:

> EJB 3.2 section "Injection of EJB References" has been fixed and now
> describes @EJB annotation elements in more details. In particular it says
>
> "The name element refers to the name by which the resource is to be looked
> up in the environment."
>

Thanks.

So @EJB(name = "java:app/Foo", lookup = "java:app/Bar") is intended to be
legal?

Dumb, but legal?

Next question (related to
http://stackoverflow.com/questions/17985337/from-an-ear-files-application-xml-deployment-descriptor-how-do-i-override-a-m
):

If I have this in my .ear's lib directory:

@ManagedBean // yeah, yeah, I know; but
https://www.google.com/search?q=jax-rs+managedbean
public class ManagedBean {
  @EJB(name = "*java:app/Foo*")
  private *Foo* foo;
}

...and in my application I pack up only one EJB that implements Foo, I
should need no other configuration for this reference to work, correct?

If I package up two EJBs that implement Foo, then I need to add an
<ejb-local-ref> element in (say) my ear file's
META-INF/application.xmlfile, right, like this:

<ejb-local-ref>
  <ejb-ref-name>*java:app/Foo*</ejb-ref-name>
  <ejb-link>someJar.jar#*FooEJB*</ejb-link>
</ejb-local-ref>

I've found that this does not work in GlassFish 3.1.2.2. Is this a bug?

Best,
Laird

-- 
http://about.me/lairdnelson