• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JNDI Question...

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm sucessfully getting session ebj from a servlet with...
Context ctx = new InitialContext();
Object obj = ctx.lookup(java:comp/env/ejb/EmployeeProcessorHome);
...and I can do the same for my entity ejb
Object obj = ctx.lookup(java:comp/env/ejb/EmployeeHome);
But when I try and get hold of the entity ejb from within the session ejb I get the error...
javax.naming.NameNotFoundException: Name comp/env/ejb not found in context "java:".
I've read that you access an ejb from another ejb in the same way that a client would, so I can't work out what's going wrong here.
Any ideas?
TIA
Dave
 
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You generally look components up using the "java:comp/env" when you define references to them in the deployment descriptors. Have you defined references to your EJBs inside your web application (web.xml) deployment descriptor?
To look up an entity bean from a session bean you have two choices.
(1) Look it up through the global JNDI name (i.e. the name that is defined in the deployment descriptor).
(2) Look it up through a "symbolic reference" where you define a reference to the entity bean inside the session bean deployment descriptor.
Is that of any use?
Simon
 
Dave Hewitson
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Simon - thanks for replying.
I definately have the references setup in web.xml - I can use the java:comp/env/ejb/EmployeeHome in the servlet, just not when I try and do the same thing from within the session ejb - It's as though the Context ctx = new InitialContext(); line gives different things in each case.
I'm not sure what you mean by a "symbolic reference" I thought the two options open to me were to use reference (ie java:comp...) or just directly (ie ejb/EmployeeHome).
Do you have any further info on this?
Dave.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic