dev@glassfish.java.net

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

From: Cheng Fang <Cheng.Fang_at_Sun.COM>
Date: Fri, 19 May 2006 08:40:38 -0400

Hi, Peter,

jndi-name for MDB is a bit different from one for session/entity beans:
MDB client don't look up an MDB, so there is no need for the local
(logical jndi-name).

MDB is tied to external JMS resource at deployment time, and this is the
info a user/deployer should provide during deployment time. The
corresponding JMS resource is sort of the real identity of the MDB. So
appserver cannot assign any meaningful physical name to it untill the
user provides the JMS resource, either through jndi-name in sun-ejb.jar
or message-destination-ref in (ejb-jar.xml, application-client.xml and
sun-ejb-jar.xml).

In case of session beans, appserver can assign any arbitrary and unique
name to it, since session beans' identity doesn't dependent on any
external resources.

Just my 2 cents.

Cheng




Peter Williams wrote:

> Comments inline...
>
> Hong Zhang wrote:
>
>> 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).
>
>
> Thanks for this information.
>
> I can work with this. I was hoping for a default name though :(
> I will have to generate a jndi-name for the NetBeans user in cases
> where they do not specify a mapped name in the MDB wizard. This is
> trivial, but if they later add a mapped name to the bean, it may cause
> a bit of runtime confusion since they will also have to manually
> delete the jndi-name we created for them. There is no easy way to
> inform them about this.
>
> I will file a bug against the verifier then since it should have
> flagged my lack of both mapped-name and jndi-name as an error.
>
> -Peter
>
>>
>> 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
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>