5 Replies Latest reply on Apr 28, 2011 6:08 AM by Stefano Zaccaria

    EntitiManager and Observer("org.jboss.seam.postInitialization")

    marx3 Apprentice

      How to get entityManager in class which is run via
      @Observer(org.jboss.seam.postInitialization) ?
      I've tried


      @PersistenceContext
      private EntityManager em;
      


      but it doesn't work.


      I've tried


      @In private EntityManager entityManager;



      and


      EntityManager em = (EntityManager) Component.getInstance("entityManager");
      



      but I have exception



      15:22:54,745 INFO  [Contexts] starting up: org.jboss.seam.security.facesSecurityEvents
      15:26:19,560 ERROR [[/smo]] Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
      java.lang.IllegalArgumentException: EntityManagerFactory not found in JNDI : java:/>xxxEntityManagerFactory
              at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManagerFactoryFromJndiOrValueBinding(ManagedPersistenceContext.java:247)



      Components.xml and persistence.xml are seam-genned and seems  ok.


      Is it because of Seam not being completely initialised?