4 Replies Latest reply on Mar 27, 2013 4:12 PM by Nicklas Karlsson

    @Inject session bean into war

    klind Newbie

      JBoss 7.1.1-final

       

      I have a Simple session bean in the EJB module, and inject this session bean in a class in the war module.

       

      But I get a NullPointerException when runnig the code... injection is not working..

      I got a setup that is very similar to this where it works, and I can't seem to find any differences on how the injection is done..

       

      I do not use the injected sessionbean in the constructor.

       

       

      @Stateless(name = "HibernateUtilsSBBean", mappedName = "jsi/ejb/HibernateUtilsSBBean")
      public class HibernateUtilsSBBean implements HibernateUtilsSBBeanLocal, HibernateUtilsSBBeanRemote {
           ......
      }
      

       

       

      @Local
      public interface HibernateUtilsSBBeanLocal {
      ....
      }
      

       

       

      @Remote
      public interface HibernateUtilsSBBeanRemote {
      ...
      }
      

       

       

      pojo class in the web app that @Inject sessionbean. 
      
      @Inject
          private HibernateUtilsSBBeanLocal hibernateUtils;
      
      

       

       

      Maven project.. 
      EAR
           - WAR
                - WEB-INF
                     beans.xml
                     classes
                          com.foo.... class that @Inject sesison bean interface
           - EJB
                - META-INF
                     beans.xml
           - META-INF
                beans.xml
                com.foo.... session bean class
           lib
               jar-containing-interfaces