Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

JNDI Lookup

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am trying to use entity beans within Session bean (2.0). Following are the steps followed

1.From the servlet i have made the jndilookup to session bean.
2.I am successfully able to make the session bean lookup
3.I have put some logs on the session bean method, that is getting printed after that i make a similar jndi lookup what i had made in the servlet, but this time it is for the Entity bean.

I am keeping getting error saying
javax.naming.NameNotFoundException: Context: widCell/nodes/widNode/servers/server1, name: com/Life_BeanLocalHome: First component in name com/Life_BeanLocalHome not found. Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL mg.org/CosNaming/NamingContext/NotFound:1.0

I have cross checked the jndi name against the ejb jar.xml those are correct and also i have given ejb references in the web.xml.

I would like to know how to solve the JNDI lookup Error, which works fine for the session bean but for Entity bean it is giving the above error, both are in same jar.

Thanks
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only session beans should interact with entity beans. Servlet should not talk to entity beans, it should invoke session bean and then session bean should invoke entity beans
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JNDI code for looking up a Session EJB should not be in the Java servlet.

Check out the Business Delegate design pattern for the Java EE way of handling this communication.

Servlet should call coarse-grained business method of Business Delegate.

Business Delegate then, optionally uses Service Locator, connects to Session EJB and calls business method.

In the code of the Session EJB, then the Entity EJB is created and processed.

When the Session EJB is done processing, it either returns nothing, throws an Exception to the Business Delegate, or returns a data object to the Business Delegate.

The Business Delegate then returns the data object to the servlet.

JNDI lookup code goes in Business Delegate to locate Session EJB.

JNDI lookup code goes in Service Locator to locate Entity EJB.
[ September 12, 2008: Message edited by: James Clark ]
 
rudresh kumar
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I could discover the problem, When ever we create entity bean in wsad, we should map the datasource for that entity bean in ejb-jar.xml. Unless this is done JNDI lookup of the enity bean will not be successful.

Thank you
 
I'm sure glad that he's gone. Now I can read this tiny ad in peace!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic