Local session bean lookup in another local session bean in EJB 3.0
Hi,
I am doing JNDI lookup of a local session bean in a session bean. ( I do not want to use EJB dependency injection).
Lookup of local interface from session bean is successful. But, when the calling session bean is a local session in another session bean, the lookup fails.
Here is an example:
@Stateless
@EJBs({@EJB(name="EJB2Local", beanInterface=EJB2Local.class),
@EJB(name="EJB3Local", beanInterface=EJB3Local.class)})
public class EJB1 implements EJB1Remote, EJB1Local{
public void findEJB3Local(){
//1. JNDI lookup for EJB3Local -
//2. EJB3Local.someFunction()
}
}
@Stateless
@EJB(name="EJB1Local", beanInterface=EJB1Local.class)
public class EJB2 implements EJB2Remote, EJB2Local{
public void findEJB1Local(){
//1. JNDI lookup EJB1Local
// 2. Call EJB1Local.findEJB1Local method
}
//THIS METHOD CALL WILL FAIL.
public void findEJB1Remote(){
//1. JNDI lookup EJB1
/ 2. Call EJB1Local.findEJB1 method
}
}
@Stateless
public class EJB3 implements EJB3Remote, EJB3Local{
public void someFunction(){}
}
This setup was working in EJB 2.1, as we had clear ejb-local-ref definitions in our ejb-jar.xml file.
I am suspecting that EJB 3.0 has special annotation to use when lookup is made from another local session bean.
Any comments will be appreciated.
Thanks,
Mohan

