1 Reply Latest reply on Aug 28, 2013 4:09 AM by Marek Novotny

    Inject EJB with @EJB annotation in Seam Component

    terry sulivan Newbie

      We are trying to migrate part of our code from Seam 2 to javaEE6 standard. In the front end, we'll still use seam annotations but on backend we'll use only javaEE6 annotations, and won't use anymore the @Name and @In annotations.

      Everything went ok when we injected the new backend EJBs in seam 2 components by this way:

      @EJB(name="ExampleServiceBean") private ExampleService exampleServiceBean;

      but ... this piece of code only works when injection takes place in EJB Seam Component.

      When the Seam component is a simple POJO, when we try to inject the backend ejb with @EJB annotation, we get all the time NullPointerException.

      • In code words, when we remplace:

      Seam component:

      @In(name="ExampleServiceBean") private ExampleService exampleServiceBean;`

      Ejb Seam component:

      @Stateless @TransactionAttribute(REQUIRED) @Name("ExampleServiceBean") public class ExampleServiceBean implements ExampleService{

      by

      Seam component:

      @EJB(name="ExampleServiceBean") private ExampleService exampleServiceBean;

      Standard ejb:

      @Stateless @TransactionAttribute(REQUIRED) @Name("ExampleServiceBean") public class ExampleServiceBean implements ExampleService{

      we get a NullPointerException.