This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes EJB naming environment related questions ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "EJB naming environment related questions ?" Watch "EJB naming environment related questions ?" New topic
Author

EJB naming environment related questions ?

gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

i have question regarding the naming environment provided to jee component. I have read various blogs and there has been some confusion regarding the namespaces. I am still not fully clear about how the naming environment works . I would like to sum up my understanding here and request ranchers to correct/enhance it.

1. in jee 5 there is no logical namespaces like java:module, java:app and java:global. they were introduced in jee 6. in jee 5 there was only java:comp.

2. now here I have a doubt. in jee 6 when a application say ejb module is deployed on app server do the ejb's gets binded to naming environment automatically ? my understanding is that in jee 6 even if you don't name your ejb components they get DEFAULT JNDI NAMES based on application name/module name/component name and they automatically gets bind to classic namespaces(ejbLocal: ) and namespaces introduced in jee 6 i.e. java:module, java:app,java:global. the classic namespace is given here http://pic.dhe.ibm.com/infocenter/wasinfo/v8r0/index.jsp?topic=%2Fcom.ibm.websphere.nd.multiplatform.doc%2Finfo%2Fae%2Fae%2Fcejb_bindingsejbfp.html.so as per my understanding if I have a ejb with ejb-name say MyBean in ejbmodule-jar.jar then the bean will have jndi names as below:
java:global/ejbmodule-jar/MyBean
java:module/MyBean
java:app/ejbmodule-jar/MyBean

However I have some doubt. in the format application name/module name/component name what is component(in context of ejbs). is it the ejb instance name or business interface name ?


3. references don't get automatically added in java:comp namespace. you have to explicitly add them. can I get example say I have a servlet and I would like to inject an ejb from my servlet through servlets private namespace. ?
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10242
    
168

gurpeet singh wrote:

1. in jee 5 there is no logical namespaces like java:module, java:app and java:global. they were introduced in jee 6. in jee 5 there was only java:comp.

That's correct.

gurpeet singh wrote:
2. now here I have a doubt. in jee 6 when a application say ejb module is deployed on app server do the ejb's gets binded to naming environment automatically ?
...
if I have a ejb with ejb-name say MyBean in ejbmodule-jar.jar then the bean will have jndi names as below:
java:global/ejbmodule-jar/MyBean
java:module/MyBean
java:app/ejbmodule-jar/MyBean

However I have some doubt. in the format application name/module name/component name what is component(in context of ejbs). is it the ejb instance name or business interface name ?

Yes, the EJBs will be bound to the java:global, java:module and java:app namespaces by default.

The component name is the name of the "component" which by default is the simple class name of the EJB implementation class. It however can be overridden using the "name" attribute of the @Stateless, @Stateful or @SIngleton EJB or even in ejb-jar.xml.

gurpeet singh wrote:
3. references don't get automatically added in java:comp namespace. you have to explicitly add them. can I get example say I have a servlet and I would like to inject an ejb from my servlet through servlets private namespace. ?

java:comp is component specific namespace which the user has to setup explicitly either via deployment descriptor (ejb-ref or resource-ref for example) or via annotation (@EJB or @Resource for example)

[My Blog] [JavaRanch Journal]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB naming environment related questions ?