1 Reply Latest reply on Oct 24, 2012 1:55 AM by sfcoy

    CDI muliple Modules

    eagle1985

      Hi @all

       

      I have a Problem with CDI. I can not inject a Klasse that is @Named with CDI if the class is in a different jar. In that Case I get a NullPointerException everytime i try to use the Variable that has the @Inject annotation.

      Anyone an Idea what to do?

       

      MyEarApp.ear looks like this:

      *MyApp.ear

      **MyApp-Core.jar

      ***META-INF

      ****beans.xml

      ****persistence.xml

      ***src

      ****...MyService

      **MyApp-UI1.war

      ***META-INF

      ****beans.xml

      ***WEB-INF

      ****beans.xml

      ****web.xml

      ****faces-config.xml

      ***lib

      ****MyUI1-Lib-only.jar

      ***classes

      ****...

      **MyApp-UI2.war

      ***META-INF

      ****beans.xml

       

      I try to call the Service from (App-Core.jar) in UI1 like this:

       

      @Inject
      private MyService service;
      

       

      as soon as I call a method in MyService I get the NPE.

      CDI within MyUI1.war works fine.

       

      And last here the Class MyService

      @Named
      @SessionScoped
      public class ProductServices implements Serializable {
      
           private static final long serialVersionUID = 1L;
           private List<Aircraft> aircrafts;
           @Inject
           private TblAcFacade acFacade;
           
           @Inject
           private Logger log;
      
           @Produces
           @Named
           public List<Aircraft> getAircrafts() {
                return aircrafts;
           }
             
             ...
      }
      

       

      Anyone can help me out?

       

      Thanks in advance