i have an issue of saving a reference to an EJB as a member from a non EJB class (which is used as static member in an EJB)
say i have
@EJB(...)
@Stateless
public Class SessionBean implements MySession{
protected static MyHelper helper = new MyHelper();
}
public Class MyHelper{
protected AnotherSessionBean ejb = lookup("jndi");
public void doSomething(){
ejb.foo();
}
}
since the helper class is not an EJB then i have a method for lookup called int the member instantiating. with this code i got in runtime an exception java.lang.NoClassDefFoundError: Could not initialize class on the SessionBean class.
when i changed MyHelper to this it worked :
public Class MyHelper{
protected AnotherSessionBean getEjb(){
return (AnotherSessionBean)lookup("jndi");
}
public void doSomething(){
getEjb().foo();
}
}
wondering why first way didn't work...