• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

EJB references

 
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Here is an example.


The developer writes code like this.
 
william kane
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

-Andy
 
reply
    Bookmark Topic Watch Topic
  • New Topic