javax.persistence.PersistenceException: java.lang.NullPointerException

Hibernate JIRA | Andy Gerweck | 1 decade ago
  1. 0

    When creating an entity manager *without* an overriding property map using javax.persistence.Persistence, I get the following exception: Exception in thread "main" javax.persistence.PersistenceException: java.lang.NullPointerException at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:173) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:103) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27) at com.tacnode.health.EntityManagerModel.main(EntityManagerModel.java:25) Caused by: java.lang.NullPointerException at org.hibernate.ejb.packaging.PersistenceXmlLoader.deploy(PersistenceXmlLoader.java:68) at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:139) ... 4 more This method is exactly how you recommend creating an entity manager in the documentation (section 2.2): `EntityManagerFactory emf = Persistence.createEntityManagerFactory(null);` All my configuration is in persistence.xml, so I don't have any hibernate.cfg.xml either. This calls through with a null Map, which is correctly handled in Ejb3Configuration.createEntityManagerFactory but not PersistenceXmlLoader. I've attached a patch that corrects this bug by skipping the override lookups if the override map is null. You could also just do a `if (overrides == null) overrides = new Properties()` in HibernatePersistence.createEntityManagerFactory(String, Map).

    Hibernate JIRA | 1 decade ago | Andy Gerweck
    javax.persistence.PersistenceException: java.lang.NullPointerException
  2. 0

    When creating an entity manager *without* an overriding property map using javax.persistence.Persistence, I get the following exception: Exception in thread "main" javax.persistence.PersistenceException: java.lang.NullPointerException at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:173) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:103) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27) at com.tacnode.health.EntityManagerModel.main(EntityManagerModel.java:25) Caused by: java.lang.NullPointerException at org.hibernate.ejb.packaging.PersistenceXmlLoader.deploy(PersistenceXmlLoader.java:68) at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:139) ... 4 more This method is exactly how you recommend creating an entity manager in the documentation (section 2.2): `EntityManagerFactory emf = Persistence.createEntityManagerFactory(null);` All my configuration is in persistence.xml, so I don't have any hibernate.cfg.xml either. This calls through with a null Map, which is correctly handled in Ejb3Configuration.createEntityManagerFactory but not PersistenceXmlLoader. I've attached a patch that corrects this bug by skipping the override lookups if the override map is null. You could also just do a `if (overrides == null) overrides = new Properties()` in HibernatePersistence.createEntityManagerFactory(String, Map).

    Hibernate JIRA | 1 decade ago | Andy Gerweck
    javax.persistence.PersistenceException: java.lang.NullPointerException
  3. 0

    Problems with ContextListener

    Oracle Community | 1 decade ago | 843842
    java.lang.ExceptionInInitializerError
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Play2.11 Play can not find the model class but I can run pure JPA Junit test properly, Please come to help, thanks

    Stack Overflow | 3 years ago | LWang
    javax.persistence.PersistenceException: [PersistenceUnit: DEVUnit] class or package not found
  6. 0

    About using MySQL Database

    GitHub | 4 years ago | romaar
    javax.persistence.PersistenceException: [PersistenceUnit: release] Unable to build EntityManagerFactory

    4 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at org.hibernate.ejb.packaging.PersistenceXmlLoader.deploy()
    2. Hibernate EJB
      HibernatePersistence.createEntityManagerFactory
      1. org.hibernate.ejb.packaging.PersistenceXmlLoader.deploy(PersistenceXmlLoader.java:68)
      2. org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:139)
      3. org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:103)
      3 frames
    3. JavaEE 7
      Persistence.createEntityManagerFactory
      1. javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
      2. javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27)
      2 frames
    4. com.tacnode.health
      EntityManagerModel.main
      1. com.tacnode.health.EntityManagerModel.main(EntityManagerModel.java:25)
      1 frame