View RSS Feed

JNDI

Explain the difference between the look up of “java:comp/env/ejb/MyBean” and “ejb

Rate this Entry
by , 01-02-2012 at 06:27 PM (2470 Views)
The alias or logical reference java:comp/env/ejb/MyBean has always been a recommended approach as the physical JNDI location i.e. ejb/MyBean may not be guaranteed that it (specified in the code) will be present. In case the physical location is changed, code will also be broken down. Your code will not be able to get modified by the deployer. This problem is solved by the logical references which bind the logical names in the application server to the physical name. Declaration will be done of the logical names in deployment descriptors as following (web.xml and/or ejb-jar.xml). In application server specific descriptors they will get mapped to the JNDI physical locations.

For looking up a JDBC resource, either from EJB (ejb-jar.xml) or WEB (web.xml) tier, the deployment descriptor should consist of this entry:

XML Code: This is the code to define JDBC Data Source
<resource-ref>
<description>The DataSource</description>
<res-ref-name>jdbc/MyDataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

Submit "Explain the difference between the look up of “java:comp/env/ejb/MyBean” and “ejb" to Facebook Submit "Explain the difference between the look up of “java:comp/env/ejb/MyBean” and “ejb" to Digg Submit "Explain the difference between the look up of “java:comp/env/ejb/MyBean” and “ejb" to del.icio.us Submit "Explain the difference between the look up of “java:comp/env/ejb/MyBean” and “ejb" to StumbleUpon Submit "Explain the difference between the look up of “java:comp/env/ejb/MyBean” and “ejb" to Google

Updated 01-15-2012 at 08:23 AM by JNDI

Tags: lookup ejb Add / Edit Tags
Categories
Tutorial

Comments