More fun with local homes:
Hi all-
Q. Can a local
EJB look up another local EJB in the same EJB project?
I'm trying to do this but am getting an error:
I have a CMP bean (userPoolEntity localHome) and a Stateless Session Bean (userPoolManager, also LocalHome) in the same EJB project:
I can look up the CMP from the JNDI
test client fine as well as the Session bean. But when I get to a method in the Session bean where it tries to look up the Entity bean, I get a naming error:
javax.naming.NameNotFoundException: Name comp/env/ejb/userpool not found in context "java:".
I also get a Console error starting EJB:
Starting EJB jar: UserPoolEJB.jar
Unable to start EJB jar, UserPoolEntity: Name "userPoolEntity" is already bound to the context "local:ejb/ejb/userpool".
Unable to start EJB jar, UserPoolManager: Name "userPoolManager" is already bound to the context "local:ejb/ejb/userpool".
Here's the lookup code in my session bean (local):
String ENTITYLOCALHOME="java:comp/env/ejb/userpool/userPoolEntity";
try {
InitialContext ctxt = new InitialContext();
UserPoolEntityLocalHome home =
(UserPoolEntityLocalHome) ctxt.lookup(ENTITYLOCALHOME);
return home;
} catch (NamingException ne) {
ne.printStackTrace();
return null;
}
Here's the EJB bind file ( I stripped out the < and > chars because I know it's hard to paste XML here):
?xml version="1.0" encoding="UTF-8"?
ejbbnd:EJBJarBinding xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns:ejbbnd="ejbbnd.xmi" xmlns:ejb="ejb.xmi" xmlns:commonbnd="commonbnd.xmi" xmlns:common="common.xmi" xmi:id="EJBJarBinding_1067823339758" currentBackendId="DB2UDBNT_V72_1"
ejbJar href="META-INF/ejb-jar.xml#ejb-jar_ID"/
ejbBindings xmi:id="EnterpriseBeanBinding_1067823339758" jndiName="ejb/userpool/userPoolEntity"
enterpriseBean xmi:type="ejb:ContainerManagedEntity" href="META-INF/ejb-jar.xml#UserPoolEntity"/
/ejbBindings
ejbBindings xmi:id="EnterpriseBeanBinding_1068043090513" jndiName="ejb/userpool/userPoolManager"
enterpriseBean xmi:type="ejb:Session" href="META-INF/ejb-jar.xml#UserPoolManager"/
ejbRefBindings xmi:id="EjbRefBinding_1068077814639" jndiName="ejb/userpool/userPoolEntity"
bindingEjbRef xmi:type="common:EJBLocalRef" href="META-INF/ejb-jar.xml#EJBLocalRef_1068077814649"/
/ejbRefBindings
/ejbBindings
defaultCMPConnectionFactory xmi:id="CMPConnectionFactoryBinding_1067824135703" jndiName="jdbc/b1"/
/ejbbnd:EJBJarBinding
Seems like a circular ref. of some sort:
Should I split into two EJB projects?
BTW, if I go to my EJB project to generate RMIC code, it always shows the beans as needing to be generated, even if I just did so.
thanks!
Max