• Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB look up question  RSS feed

 
Prannav Santhosh
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an EJB (Stateless session bean) and a web module as part of my EAR.
EJB is mapped to the JNDI - "ejb/ejbs/FortuneBeanHome"

Scenario (1)
========
I added this EJB project in the build path of the Web module and in the web module i have a servlet class which has the following code.

Object hmObject =con.lookup("ejb/ejbs/FortuneBeanHome");
FortuneBeanHome homeObject = (FortuneBeanHome)PortableRemoteObject.narrow(hmObject, FortuneBeanHome.class);
FortuneBean fbean = homeObject.create();

The above code works perfect. but when i use the below code

Object hmObject =con.lookup("java:comp/env/ejb/ejbs/FortuneBeanHome");

I get an exception "javax.naming.NameNotFoundException: Name comp/env/ejb not found in context "java:"

In what scenario , should i be using "java:comp/env/" ?

Thanks !!!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!