As per the EJB specification , the role of the deployer is to ensure that "All ejb references are bound to the homes of the beans that exist in the operational environment". Does this mean that the ejb refereces have to associated with JNDI names of the referenced EJBs? Thanks in advance William Kane
Yes, it is a fundamental EJB design principle that the Bean Provider (who writes the EJBs) is assumed not to know anything about the operational environment in which the EJBs will run. So, the BP makes up a fake JNDI name, declares it in the <ejb-ref> element in the ejb-jar.xml deployment descriptor file and uses it in the code. It is the job of the Deployer to map the fake JNDI name to the real JNDI name. This is typically done in a server-specific DD file.
Originally posted by Roger Chung-Wee: The developer writes code like this.
Thank you Roger, That clarifies my query,I have a further question though 1.I have read that to access referenced ejb on should use the jndi name "java:come/env/<name of the fake reference>".Is the prefix "java:comp/env" needed in the bean access code? Thanks in advance William Kane
To clarify here a little there is no "fake" JNDI name used but a JNDI name that is only available to the bean itself. These JNDI name are listed in the "java:comp/env" namespace. Internally these local JNDI names are a link to the actual JNDI name and are therefore is a simple redirection.
That is also a reason why you should not create an Initial Context with properties because that could make the 'local' namespace unreachable.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop