2 Replies Latest reply on Jun 16, 2015 11:14 PM by jaikiran pai

    Wildfly 8 + JPA, EntityManager is null for stateless bean

    Kaptain Maskat Newbie

      Hi,

       

      EntityManager appears to be always null when I turn to findUser method in Login class, could you please help me with solving this issue?

       

      @Stateless(name = "Login")
      @TransactionManagement(TransactionManagementType.CONTAINER)
      public class Login  {
      
         @PersistenceContext(unitName = "test")
        EntityManager em;
      
         public boolean findUser(String userid, String passwd) { 
      if (em == null) {
        System.out.println("EntityManager is null");
         return false;
      }
      ...
      
      }
      

       

      Persistence.xml file:

       

      <persistence-unit name="test">

         <jta-data-source>java:/puDS</jta-data-source>

         <properties>

         </properties>

      </persistence-unit>

       

      From the logs I see that deployment picks up the persistence unit and shows the details for it.

       

      Thank you,

      Kaptain