Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JNDI Lookup  RSS feed

 
rudresh kumar
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
 
aleem khan
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
 
Jimmy Clark
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!