Win a copy of liveProject: Protecting User Data with Spring Security and OAuth2 this week in the Spring forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

EJB naming environment related questions ?

 
Ranch Hand
Posts: 924
1
Netbeans IDE Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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. ?
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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)
 
reply
    Bookmark Topic Watch Topic
  • New Topic