This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes ejb jndi name confused me Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "ejb jndi name confused me" Watch "ejb jndi name confused me" New topic

ejb jndi name confused me

zb cong
Ranch Hand

Joined: Jan 14, 2002
Posts: 416
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!
Tualha Khan
Ranch Hand

Joined: Nov 22, 2000
Posts: 287
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

SCJP2, BEA WLS 6.0, DB2 UDB 7.1
Ranch Hand

Joined: Jul 06, 2001
Posts: 257
They both work. If I define a reference to an EJB in my weblogic-jar.xml file like this:
..then I could use:
Object objref = initial.lookup("java:comp/env/ejb/sr/employeeSearch");
Object objref = initial.lookup("EmployeeSearch"); 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.
zb cong
Ranch Hand

Joined: Jan 14, 2002
Posts: 416
thank you very much for your instruction!
Have you checked out Aspose?
subject: ejb jndi name confused me
It's not a secret anymore!