• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ejb jndi name confused me

 
Ranch Hand
Posts: 416
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello
i am a beginner to ejb,in my book,somtimes it use following fomat to lookup the home:

Object objref=initial.lookup("java:comp/env/ejb/MyEjb");

but sometimes,it use another format as following:

Object objref=initial.lookup("MyEjb");

what's the difference between them?
and when use what format?
thanks for any helps!
 
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I maybe wrong, but the former is used for command line applications or applications and the latter is used for web apps.
Any Suggestions here???
Thanks & Bye,
Tualha Khan
 
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
They both work. If I define a reference to an EJB in my weblogic-jar.xml file like this:
<ejb-reference-description>
<ejb-ref-name>ejb/sr/employeeSearch</ejb-ref-name>
<jndi-name>EmployeeSearch</jndi-name>
</ejb-reference-description>
..then I could use:
Object objref = initial.lookup("java:comp/env/ejb/sr/employeeSearch");
..or:
Object objref = initial.lookup("EmployeeSearch");
..to find the home interface.
In the first case, you are using the default jndi context "java:comp/env/" + ejb-ref-name as defined in weblogic-jar.xml. In the second case, you are using the actual JNDI name of the EJB. The first case is the recommended approach.
SAF
 
zb cong
Ranch Hand
Posts: 416
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you very much for your instruction!
 
reply
    Bookmark Topic Watch Topic
  • New Topic