1 Reply Latest reply on May 11, 2010 7:57 PM by Wujek Srujek

    Strange behaviour with @PersistenceContext

    Diego Coronel Apprentice

      Hi,


      This is my project structure:


      - WebProject
           - WebContent
              - lib
                 - core.jar


      Both, WebProject and Core.jar are with beans.xml in meta-inf folder. So, my problem is that if i try to use my persistenceContext provider in core.jar it does not work. im getting an error saying that a producer cant return null, but, if i recort this same provider to WebProject it works. So, shouldnt it work in both cases?


      my provider:



      public class Provider {
      
           @PersistenceContext( unitName = "DfpcUnit" )
           private EntityManager entityManager;
      
           @PersistenceUnit( unitName = "DfpcUnit" )
           private EntityManagerFactory emf;
      
           @Produces @RequestScoped @Database 
           public EntityManager getEntityManager() {
                return entityManager;
           }
      
           @Produces @RequestScoped 
           public EntityManagerFactory getEmf() {
                return emf;
           }
           
      }