aspose file tools*
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
Author

ejb jndi name confused me

zb cong
Ranch Hand

Joined: Jan 14, 2002
Posts: 416
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!
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
SAFROLE YUTANI
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:
<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

Joined: Jan 14, 2002
Posts: 416
thank you very much for your instruction!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ejb jndi name confused me