users@glassfish.java.net

Re: lookup local slsb from a pojo

From: <glassfish_at_javadesktop.org>
Date: Tue, 19 May 2009 08:10:12 PDT

Tim,

we had exactly the same problem and the EJB_FAQ is *NOT* clear about this, I agree. Finally we figured it out, thanks to this link: http://openejb.apache.org/3.0/ejb-local-ref.html


You need to put the @EJB annotation with name and class of the local interface that you are trying to lookup on top of the SessionBean that does the lookup. In JBoss there was no need for this, but here there is (I'm not sure why, as it seems to be redundant boiler-plate code).

Example:

SessionBean being looked up:

@Stateless
public class CoreBean implements CoreLocal {
....



SessionBean doing the lookup:

@Stateless
@EJB(name = "myFooEjb", beanInterface = CoreLocal.class)
public class CoreFacadeBean implements CoreFacade {


public void someMethod() {
   CoreLocal coreBean = (CoreLocal) ctx.lookup("myFooEjb");
   ...
}


I hope this is clear enough. If not, let me know.

- Andreas
[Message sent by forum member 'ansis' (ansis)]

http://forums.java.net/jive/thread.jspa?messageID=346798