javax.persistence.PersistenceException: [PersistenceUnit: capacity] Unable to build Hibernate SessionFactory

Hibernate JIRA | ChB | 2 weeks ago
tip
Do you find the tips below useful? Click on the to mark them and say thanks to poroszd . Or join the community to write better ones.
  1. 0
    samebug tip
    I was using the library hibernate-entitymanager:4.3.5.Final with java persistence API 2.0 instead of using it with hibernate-entitymanager:4.2.8.Final.
  2. 0

    I've recently tried to upgrade from hibernate 5.2.2 to 5.2.9 which caused the application to no longer work. I have the following mapping: @Embeddable public class AbilityEntity { } public class EmployeeEntity { @BatchSize(size = 10) @ElementCollection(fetch = FetchType.EAGER) @CollectionTable(name = "ability", joinColumns = @JoinColumn(name = "employee_id") ) public Set<AbilityEntity> getAbilities() { ... } } Starting from 5.2.3 on I'm getting the following error: {{13-May-2017 01:31:17.518 SEVERE [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.core.StandardContext.filterStart Exception starting filter EntityManagerFilter javax.persistence.PersistenceException: [PersistenceUnit: capacity] Unable to build Hibernate SessionFactory at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:951) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:881) at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:58) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39) at de.egore911.capacity.ui.filter.EntityManagerFilter.init(EntityManagerFilter.java:58) at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260) at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4659) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5281) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.startup.HostConfig.reload(HostConfig.java:1390) at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1291) at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1552) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:285) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90) at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1141) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1377) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1381) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1349) at java.lang.Thread.run(Thread.java:745) Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [ability] at org.hibernate.tool.schema.internal.AbstractSchemaValidator.validateTable(AbstractSchemaValidator.java:121) at org.hibernate.tool.schema.internal.GroupedSchemaValidatorImpl.validateTables(GroupedSchemaValidatorImpl.java:42) at org.hibernate.tool.schema.internal.AbstractSchemaValidator.performValidation(AbstractSchemaValidator.java:89) at org.hibernate.tool.schema.internal.AbstractSchemaValidator.doValidation(AbstractSchemaValidator.java:68) at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:185) at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:66) at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:309) at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:493) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:878) ... 21 more}} It works when downgrading to 5.2.2 again. What's also interesting is that it works fine on Apache Tomcat 8.5.12 on JDK 1.8.0_102-b14 (Windows), while it does not Apache Tomcat 8.0.30 on JDK 1.8.0_77-b03 (Linux). Source code of said affected application is at https://github.com/egore/capacity-web

    Hibernate JIRA | 2 weeks ago | ChB
    javax.persistence.PersistenceException: [PersistenceUnit: capacity] Unable to build Hibernate SessionFactory
  3. 0

    "Not known whether passed class name ... is safe" using JPA EmbeddedId with Hibernate

    Stack Overflow | 2 years ago | Joshua Taylor
    javax.persistence.PersistenceException: [PersistenceUnit: unit] Unable to build Hibernate SessionFactory
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0
    samebug tip
    Since:Java Persistence 2.1
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. org.hibernate.tool.schema.spi.SchemaManagementException

    Schema-validation: missing table [ability]

    at org.hibernate.tool.schema.internal.AbstractSchemaValidator.validateTable()
  2. org.hibernate.tool
    SchemaManagementToolCoordinator.process
    1. org.hibernate.tool.schema.internal.AbstractSchemaValidator.validateTable(AbstractSchemaValidator.java:121)
    2. org.hibernate.tool.schema.internal.GroupedSchemaValidatorImpl.validateTables(GroupedSchemaValidatorImpl.java:42)
    3. org.hibernate.tool.schema.internal.AbstractSchemaValidator.performValidation(AbstractSchemaValidator.java:89)
    4. org.hibernate.tool.schema.internal.AbstractSchemaValidator.doValidation(AbstractSchemaValidator.java:68)
    5. org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:185)
    6. org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:66)
    6 frames
  3. Hibernate
    SessionFactoryImpl.<init>
    1. org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:309)
    1 frame
  4. org.hibernate.boot
    SessionFactoryBuilderImpl.build
    1. org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:493)
    1 frame
  5. org.hibernate.jpa
    HibernatePersistenceProvider.createEntityManagerFactory
    1. org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:878)
    2. org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:58)
    2 frames
  6. JavaEE 7
    Persistence.createEntityManagerFactory
    1. javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
    2. javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
    2 frames
  7. de.egore911.capacity
    EntityManagerFilter.init
    1. de.egore911.capacity.ui.filter.EntityManagerFilter.init(EntityManagerFilter.java:58)
    1 frame
  8. Glassfish Core
    ContainerBase$ContainerBackgroundProcessor.run
    1. org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
    2. org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
    3. org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
    4. org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4659)
    5. org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5281)
    6. org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    7. org.apache.catalina.startup.HostConfig.reload(HostConfig.java:1390)
    8. org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1291)
    9. org.apache.catalina.startup.HostConfig.check(HostConfig.java:1552)
    10. org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:285)
    11. org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95)
    12. org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    13. org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1141)
    14. org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1377)
    15. org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1381)
    16. org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1349)
    16 frames
  9. Java RT
    Thread.run
    1. java.lang.Thread.run(Thread.java:745)
    1 frame