aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes please help me with the jndi question 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 "please help me with the jndi question" Watch "please help me with the jndi question" New topic
Author

please help me with the jndi question

kevin ou
Greenhorn

Joined: Feb 15, 2003
Posts: 23
hi All,
I have the following code to find a stateless session bean's home from the servlet:
ahome= (A_home) ctx.lookup("mySessionHome");
and my weblogic descriptor xml is like this
<weblogic-enterprise-bean>
<ejb-name>MySessionBean</ejb-name>
<jndi-name>mySessionHome</jndi-name>
</weblogic-enterprise-bean>
This works. However if I want to put that into java:comp/env/ejb
like the following:
<weblogic-enterprise-bean>
<ejb-name>MySessionBean</ejb-name>
<jndi-name>ejb/mySessionHome</jndi-name>
</weblogic-enterprise-bean>
and my code is like
ahome= (A_home) ctx.lookup("java:comp/env/ejb/mySessionHome");
then I got error unresolved:'ejb'; it gives me the javax.naming.NameNotFoundException;
Can anyone please tell me that why I can't use java:comp/env/ejb to locate the session bean's home.
Thank you!
kevin
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
The JNDI name you specify in your weblogic-ejb-jar.xml is the bean's real JNDI name. In order to use the private "java:comp/" context, you need to declare an EJB reference (ejb-ref) in your ejb-jar.xml. Do a little search for "ejb-ref" and you'll find answers.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
 
 
subject: please help me with the jndi question
 
Similar Threads
problem in acessing session bean using jndi
DataSource in ejb-jar.xml
JNDI Name format
problems with JNDI name lookup
Local EJB call - Naming Exception