users@glassfish.java.net

Re: name resolution in JNDI WRT Annotations

From: Sivakumar Thyagarajan <Sivakumar.Thyagarajan_at_Sun.COM>
Date: Wed, 15 Mar 2006 22:26:01 +0530

Hi Joseph

As Hong rightly pointed out, the sun specified deployment descriptor
[sun-ejb-jar.xml] could be used to map your logical jndi name to your
physical jndi name.

Sample ejb-jar and sun-ejb-jar.xml for MDBs and further MDB
configuration documentation is available off
https://glassfish.dev.java.net/nonav/javaee5/docs/DG/beahl.html#beait

Thanks
--Siva.


Hong Zhang wrote:
> Hi, Joseph
>
>> I'm a little lost here. I'm trying to create an MDB, but I'm not sure
>> how to look up the mapped resources - I have a queue and a connection
>> factory defined, but when I use the canonical names, they never
>> resolve. When I use netbeans to create the references, it uses a
>> "Name" attribute, but using that name doesn't resolve either; I guess
>> I'm just not sure how to connect local contexts to the global JNDI
>> context.
>>
>> Can anyone explain how this works in glassfish for me?
>>
> There are two ways you can map the logical jndi name (the resource
> reference name that you use to look up in your code) to the physical
> logic name (the name that you create the resource with, or the global
> jndi name you referred to).
>
> 1. using the sun specific deployment descriptor files
> 2. using the mappedName attribute of the Resource annotation.
>
> You can look at this simple mdb test as an example:
> http://fisheye5.cenqua.com/viewrep/glassfish/appserv-tests/devtests/ejb/ejb30/hello/mdb
>
>
> In this example, a message connector factory
> "jms/ejb_ejb30_hello_mdb_QCF" (i.e. the physical jndi name) is created:
> asadmin create-jms-resource --restype javax.jms.QueueConnectionFactory
> jms/ejb_ejb30_hello_mdb_QCF
>
> 1. And in the Client code, it uses the mappedName attribute to map the
> logical jndi name "FooCF" to the physical jndi name
> "jms/ejb_ejb30_hello_mdb_QCF"
> @Resource(name="FooCF", mappedName="jms/ejb_ejb30_hello_mdb_QCF")
> private static QueueConnectionFactory queueConFactory;
>
> 2. Alternatively, you could have this in the Client code without the
> mappedName attribute:
> @Resource(name="FooCF")
> private static QueueConnectionFactory queueConFactory;
>
> Then in the sun-application-client.xml, you will provide this mapping
> <resource-ref>
> <res-ref-name>FooCF</res-ref-name>
> <jndi-name>jms/ejb_ejb30_hello_mdb_QCF</jndi-name>
> <default-resource-principal>
> <name>guest</name>
> <password>guest</password>
> </default-resource-principal>
> </resource-ref>
>
>
> Lastly, in the Glassfish 9.0, we have implemented some runtime
> defaulting mechanism for global jndi names. When the logical jndi name
> is the same as physical jndi name, no mapping is needed. You could get
> more details on this from this blog:
> http://blogs.sun.com/roller/page/misty?entry=runtime_defaults_in_appserver9_glassfish
>
>
> Hope this helps,
>
> - Hong
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>