dev@glassfish.java.net

Re: What is the default mapped-name, if any, for an MDB in EJB3?

From: Hong Zhang <Hong.Zhang_at_Sun.COM>
Date: Thu, 18 May 2006 20:29:59 -0400

Hi, Peter

> What is the default mapped-name, if any, for an MDB in EJB3?

I don't think the current appserver implementation provides any default
mapped-name (or global jndi-name) for MDB in EJB3. It does provide some
defaults for ejb2.x/ejb3.0 session bean and ejb2.0 entity bean.

> I have an EJB Module (JavaEE5) with a single message driven bean,
> annotated via just "@MessageDriven".
>
> No mapped name, no ejb-jar.xml, and trivial sun-ejb-jar.xml (e.g no
> jndi name for this bean is specified there).
>
> When this module is deployed, what is the jndi-name of the JMS
> Resource it is looking for? The bean is named "NewMessage", in
> package "test". I've tried several permutations of
> [ejb/][test.][NewMessage] for naming the JMSResource and all
> deployments result in the same error (that there is no JMS Resource --
> but the error does not indicate the name it is looking for).
>
> Verifier, by the way, says the EJB Module is fine, no errors or warnings.
>
> So, if mapped-name is not specified, what does the server use for a
> default? Anything? Does this scenario require that the jndi-name be
> specified in sun-ejb-jar.xml or can I make this work without doing
> that (or using mapped-name either).


So in your case, you would need to

1. provide mapped-name through deployment descriptor (or mappedName
attribute within the @javax.ejb.MessageDriven annotation).
OR
2. specify the global jndi-name in sun-ejb-jar.xml

Note: when both are present, the jndi-name in sun-ejb-jar.xml overrides
the value specified through mapped-name element (or the mappedName
attribute).

You could look at this mdb dev test as an example:
http://fisheye5.cenqua.com/viewrep/glassfish/appserv-tests/devtests/ejb/ejb30/hello/mdb

Thanks,

- Hong