This content has been marked as final.
Show 3 replies
-
1. Re: Fail to lookup entity bean inside a stateless session be
waynebaylor Jul 25, 2007 9:41 AM (in response to calsonli)what's the lookup code look like?
you should be able to use:@EJB MyBeanLocal bean;
to inject the slsb. -
2. Re: Fail to lookup entity bean inside a stateless session be
calsonli Jul 26, 2007 1:33 AM (in response to calsonli)Thanks a lot for your reply, Waynebaylor.
My lookup code is as follows, which is generated from XDoclet./** * Utility class for Staff. * @xdoclet-generated at ${TODAY} * @copyright The XDoclet Team * @author XDoclet * @version ${version} */ public class StaffUtil { /** Cached local home (EJBLocalHome). Uses lazy loading to obtain its value (loaded by getLocalHome() methods). */ private static ts.interfaces.StaffLocalHome cachedLocalHome = null; private static Object lookupHome(java.util.Hashtable environment, String jndiName, Class narrowTo) throws javax.naming.NamingException { // Obtain initial context javax.naming.InitialContext initialContext = new javax.naming.InitialContext(environment); try { Object objRef = initialContext.lookup(jndiName); // only narrow if necessary if (java.rmi.Remote.class.isAssignableFrom(narrowTo)) return javax.rmi.PortableRemoteObject.narrow(objRef, narrowTo); else return objRef; } finally { initialContext.close(); } } // Home interface lookup methods /** * Obtain local home interface from default initial context * @return Local home interface for Staff. Lookup using COMP_NAME */ public static ts.interfaces.StaffLocalHome getLocalHome() throws javax.naming.NamingException { if (cachedLocalHome == null) { cachedLocalHome = (ts.interfaces.StaffLocalHome) lookupHome(null, ts.interfaces.StaffLocalHome.COMP_NAME, ts.interfaces.StaffLocalHome.class); } return cachedLocalHome; } }
Thank you,
Calson -
3. Re: Fail to lookup entity bean inside a stateless session be
waynebaylor Jul 26, 2007 1:25 PM (in response to calsonli)what's the code in the servlet that does the lookup for the first session bean?
and is the NamingException from StaffUtil or from the servlet?