You can use google guice ( http://www.tzavellas.com/techblog/2007/07/03/using-dependency-injection-in-struts2-for-stateless-ejbs-part-1/). I use it and works fine!
2009/12/4 Haroon Rafique <haroon.rafi...@utoronto.ca> > On Today at 11:58am, JC=>James Cook <james.c...@wecomm.com> wrote: > > JC> EJB's can only be injected into other EJB's or Servlets, a struts 2 > JC> action is essentially a pojo not a servlet. So you would either have to > JC> do a lookup in the context, or if you are using Spring look at using a > JC> jndi lookup and inject that reference into your class. > JC> > JC> Cookie > > Celinio, > > You can also use a Servlet simply for the purpose of invoking EJBs (let's > call it EJBInvokerServlet) and then use the @Resource notation to bring > any local EJB into your Action. See: > http://osdir.com/ml/user-struts.apache.org/2009-07/msg00842.html > > Hope that helps. > > JC> > JC> -----Original Message----- > JC> From: Fernandes Celinio [mailto:cfernan...@sopragroup.com] > JC> Sent: 04 December 2009 11:37 > JC> To: user@struts.apache.org > JC> Subject: [Struts 2 + EJB 3] injection of EJBs into struts 2 actions > JC> > JC> Hi, > JC> I know that it is not possible to inject EJB in Struts 2 actions. > JC> The following annotation would not work : > JC> @EJB > JC> MyBeanLocal mybean; > JC> > JC> But how come ? Since a Struts action is a servlet and injection works > in > JC> a servlet, injection should work. > JC> > JC> Thanks for enlightening me. > JC> > JC> > JC> --------------------------------------------------------------------- > JC> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > JC> For additional commands, e-mail: user-h...@struts.apache.org > JC> > JC> > > -- > Haroon Rafique > <haroon.rafi...@utoronto.ca> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >