Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

please help me with the jndi question

 
kevin ou
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic