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.
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 ]
posted 12 years ago
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.
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