> We have a FAQ entry that describes how to acquire EJB
> references from a class that does not support injection :
>
> https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#POJOLocalEJB
Actually, this approach does not seem to work. A NamingException is thrown; probably because the CometHandler is notified using from a different thread pool. At least this happens when you define a EJB reference using @EJB(name="MyBean", beanInterface=MyLocal.class) for the servlet, and try to do a access it using ctx.lookup("java:comp/env/MyEjb") in the CometHandler.onEvent method. The lookup works fine in the CometHandler constructor, which is called from the servlet thread.
So I guess, two approaches are left:
1.) Pass the EJB reference from the servlet to the CometHandler
2.) Create a Remote interface for the EJB and use a global JNDI name for the EJB. Then, a global lookup in the CometHandlet should work.
The first approach looks a bit quick&dirty to me, but it seems to work.
[Message sent by forum member 'markusoj' (markusoj)]
http://forums.java.net/jive/thread.jspa?messageID=288308