struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Haroon Rafique <>
Subject RE: [Struts 2 + EJB 3] injection of EJBs into struts 2 actions
Date Fri, 04 Dec 2009 13:13:36 GMT
On Today at 11:58am, JC=>James Cook <> 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> Cookie


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:

Hope that helps.

JC> -----Original Message-----
JC> From: Fernandes Celinio [] 
JC> Sent: 04 December 2009 11:37
JC> To:
JC> Subject: [Struts 2 + EJB 3] injection of EJBs into struts 2 actions
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> MyBeanLocal mybean;
JC> But how come ? Since a Struts action is a servlet and injection works in
JC> a servlet, injection should work.
JC> Thanks for enlightening me.
JC> ---------------------------------------------------------------------
JC> To unsubscribe, e-mail:
JC> For additional commands, e-mail:

Haroon Rafique

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message