Discussions

EJB programming & troubleshooting: persistentManager is null

  1. persistentManager is null (1 messages)

    Hi,

    I have Interface which is defined as


    @Local
    public interface MyPersistenceManagerLocal {

      public List getPropertyList(int id);

    }

    and implentaion class for above interface is

    @Stateless
    public class MyPersistenceManagerBean implements MyPersistenceManagerLocal {

      @PersistenceContext(unitName = PersistentSettings.PERSIST_NAME)
      private EntityManager entityManager;

      @Override
      public List getPropertyList(int id) {
        System.out.println("inside MyPersistenceManagerBean.getPropertyList()");
        ......
     ......
     ......
      }
    }


    and i am calling this in another class


    @Stateless
    public class ClientImpl implements Client {

      @EJB
      MyPersistenceManagerLocal persistenceManager;

      final List dbList = persistenceManager.getPropertyList(id);

    }
     
     i am getting NullPointerException on
      final List dbList = persistenceManager.getPropertyList(id);
    in debug mode i got persistenceManager is null.

    i am new in EJB and JPA not able to solve this. any help why i am getting persistenceManager as null
     

  2. persistentManager is null[ Go to top ]

    is your persistence context properly defined in persistence.xml file and named according to your PersistentSettings.PERSIST_NAME constant value?

    Mathieu http://simpleadn.blogspot.com