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

[1481 byte] By [kumarmc123a] at [2007-11-27 7:04:24]
# 1

From a private component environment perspective, declaring @EJB in a bean class is equivalent

to using ejb-ref or ejb-local-ref for that same bean in ejb-jar.xml.In each case, the EJB dependency

is declared for that bean.Each EJB component has its own private component environment, so

code running within invocations on different EJBs can not see the component environment of the

components that made the invocations.

What exact error are you getting? Please post the stack trace if possible.

--ken

ksaksa at 2007-7-12 18:55:41 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...