3 Replies Latest reply on Jul 30, 2011 8:36 PM by Ondrej Zizka

    Cyclic injection until OutOfMemoryError

    Ondrej Zizka Master

      Hi,


      I have a bean, JpaLoggerService, which @Inject's EntityManager.


      This EM is my own EM implementation which delegates work to Hibernate's EM.


      JpaLoggerService also has a @PostConstruct @JpaTransactional method which uses the EM.
      @JpaTransactional brings in an interceptor which initializes the Hibernate's EM


      The EM is taken from an EntityManagerFactory which is created in @ApplicationScoped EntityManagerStoreImpl's @PostConstruct method.



      Question:
      If the JpaLoggerService is @Dependent, it causes initialization recursion - EntityManagerStoreImpl is initialized many times until OutOfMemoryError is thrown.


      If the JpaLoggerService is @ApplicationScoped, it's ok.


      Shouldn't EntityManagerStoreImpl be initialized only once? How can this recursion happen if it's @ApplicationScoped?