1 Reply Latest reply on Jul 19, 2006 5:03 AM by pmuir

    Referencing another Bean

    bluetrade

      Hi,
      I have two Beans, wheras one is solely used within the other:
      @Stateful...
      Bean1 implements Bean1If {
      @In(create=true)
      EntityManager em;

      Bean2 b2 = new Bean2();
      ...
      }

      Bean2 implements Bean2If {
      @In(create=true)
      EntityManager em;

      }

      now in Bean2, if I want to access the em, I always end up with a null pointer (for Bean1 it works), I guess I cannot just say new Bean2() - but I don't know how else I would instantiate the second bean...

      Thanks,
      Joey

        • 1. Re: Referencing another Bean
          pmuir

          Try

          @Stateful
          @Name("b1")
          public class Bean1 implements Bean1If {
           @In(create=true) EntityManager em;
           @In(create=true) Bean2 b2;
           ...
          }

          @Name("b2")
          public class Bean2 implements Bean2If {
           @In(create=true) EntityManager em;
           ...
          }