1 Reply Latest reply on Aug 6, 2007 11:24 AM by alrubinger

    @EJB injection with Struts2

    prevsetko

      Hi,
      I have problem with @EJB injection in Struts action. Using context.lookup works.

      import javax.ejb.EJB;
      
      public class ProjectListAction {
      
       @EJB
       ProjectBean projectBean;
      ....
      

      projectBean remains null. Should it works also in struts?


      I am using JBoss AS 4.2 GA, <web-app ... version="2.5">

        • 1. Re: @EJB injection with Struts2
          alrubinger

          Ah; you can't inject into a Struts Action class; only into EJB3 container-managed objects (in JBoss 4.x, JBoss 5 supports Servlet Injection).

          You can replace the @EJB injection with a Context.lookup() call to JNDI to obtain your EJB proxy object.

          S,
          ALR