javax.persistence.PersistenceException: [PersistenceUnit: managed-jpa] Unable to build Hibernate SessionFactory

Hibernate JIRA | Felix Wassmer | 6 months ago
  1. 0

    After the latest envers classloader changes HHH-10365 hibernate is unable to build the SessionFactory for this case: * Entity is audited * Entity has an attribute of a different bundle When @Audited is removed from the entity, the SessionFactory is build properly. Example code to reproduce this issue: https://github.com/fwassmer/hibernate-demos/tree/classloader/hibernate-orm/osgi/managed-jpa Following exception is thrown: {noformat} 2016-06-06T12:44:16,834 | ERROR | pa.managed-jpa]) | 7 - org.apache.felix.configadmin - 1.8.8 | configadmin | [org.osgi.service.cm.ManagedService, id=167, bundle=29/mvn:org.apache.aries.jpa/org.apache.aries.jpa.container/2.3.0]: Unexpected problem updating configuration org.apache.aries.jpa.managed-jpa javax.persistence.PersistenceException: [PersistenceUnit: managed-jpa] Unable to build Hibernate SessionFactory at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:961) [123:org.hibernate.core:5.2.0.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:891) [123:org.hibernate.core:5.2.0.Final] at org.hibernate.osgi.OsgiPersistenceProvider.createContainerEntityManagerFactory(OsgiPersistenceProvider.java:96) [125:org.hibernate.osgi:5.2.0.Final] at org.apache.aries.jpa.container.impl.ManagedEMF.createAndPublishEMF(ManagedEMF.java:129) [29:org.apache.aries.jpa.container:2.3.0] at org.apache.aries.jpa.container.impl.ManagedEMF.updated(ManagedEMF.java:125) [29:org.apache.aries.jpa.container:2.3.0] at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updated(ManagedServiceTracker.java:189) [7:org.apache.felix.configadmin:1.8.8] at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(ManagedServiceTracker.java:152) [7:org.apache.felix.configadmin:1.8.8] at org.apache.felix.cm.impl.helper.ManagedServiceTracker.provideConfiguration(ManagedServiceTracker.java:85) [7:org.apache.felix.configadmin:1.8.8] at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.provide(ConfigurationManager.java:1444) [7:org.apache.felix.configadmin:1.8.8] at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.run(ConfigurationManager.java:1400) [7:org.apache.felix.configadmin:1.8.8] at org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:143) [7:org.apache.felix.configadmin:1.8.8] at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:110) [7:org.apache.felix.configadmin:1.8.8] at java.lang.Thread.run(Thread.java:745) [?:?] Caused by: org.hibernate.MappingException: Unable to instantiate custom type: org.hibernate.type.EnumType at org.hibernate.type.TypeFactory.custom(TypeFactory.java:207) ~[?:?] at org.hibernate.type.TypeFactory.custom(TypeFactory.java:193) ~[?:?] at org.hibernate.type.TypeFactory.byClass(TypeFactory.java:107) ~[?:?] at org.hibernate.type.TypeResolver.heuristicType(TypeResolver.java:112) ~[?:?] at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:401) ~[?:?] at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:383) ~[?:?] at org.hibernate.mapping.Property.isValid(Property.java:226) ~[?:?] at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:595) ~[?:?] at org.hibernate.mapping.RootClass.validate(RootClass.java:265) ~[?:?] at org.hibernate.boot.internal.MetadataImpl.validate(MetadataImpl.java:329) ~[?:?] at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:475) ~[?:?] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:888) ~[?:?] ... 11 more Caused by: org.hibernate.HibernateException: Enum class not found: org.broken.datatype.DataTypeEnum at org.hibernate.type.EnumType.setParameterValues(EnumType.java:108) ~[?:?] at org.hibernate.type.TypeFactory.injectParameters(TypeFactory.java:142) ~[?:?] at org.hibernate.type.TypeFactory.custom(TypeFactory.java:203) ~[?:?] at org.hibernate.type.TypeFactory.custom(TypeFactory.java:193) ~[?:?] at org.hibernate.type.TypeFactory.byClass(TypeFactory.java:107) ~[?:?] at org.hibernate.type.TypeResolver.heuristicType(TypeResolver.java:112) ~[?:?] at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:401) ~[?:?] at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:383) ~[?:?] at org.hibernate.mapping.Property.isValid(Property.java:226) ~[?:?] at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:595) ~[?:?] at org.hibernate.mapping.RootClass.validate(RootClass.java:265) ~[?:?] at org.hibernate.boot.internal.MetadataImpl.validate(MetadataImpl.java:329) ~[?:?] at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:475) ~[?:?] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:888) ~[?:?] ... 11 more Caused by: java.lang.ClassNotFoundException: org.broken.datatype.DataTypeEnum not found by org.hibernate.core [123] at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1574) ~[?:?] at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:79) ~[?:?] at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2018) ~[?:?] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:?] at java.lang.Class.forName0(Native Method) ~[?:?] at java.lang.Class.forName(Class.java:348) ~[?:?] at org.hibernate.internal.util.ReflectHelper.classForName(ReflectHelper.java:151) ~[?:?] at org.hibernate.type.EnumType.setParameterValues(EnumType.java:105) ~[?:?] at org.hibernate.type.TypeFactory.injectParameters(TypeFactory.java:142) ~[?:?] at org.hibernate.type.TypeFactory.custom(TypeFactory.java:203) ~[?:?] at org.hibernate.type.TypeFactory.custom(TypeFactory.java:193) ~[?:?] at org.hibernate.type.TypeFactory.byClass(TypeFactory.java:107) ~[?:?] at org.hibernate.type.TypeResolver.heuristicType(TypeResolver.java:112) ~[?:?] at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:401) ~[?:?] at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:383) ~[?:?] at org.hibernate.mapping.Property.isValid(Property.java:226) ~[?:?] at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:595) ~[?:?] at org.hibernate.mapping.RootClass.validate(RootClass.java:265) ~[?:?] at org.hibernate.boot.internal.MetadataImpl.validate(MetadataImpl.java:329) ~[?:?] at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:475) ~[?:?] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:888) ~[?:?] ... 11 more {noformat} It seems the org.hibernate.core bundle tries to lookup the class DataTypeEnum with the wrong classloader, looking only in it's own bundle and imports, not in the bundle providing the persistence context (managed-jpa in this case, which has the class in it's imports).

    Hibernate JIRA | 6 months ago | Felix Wassmer
    javax.persistence.PersistenceException: [PersistenceUnit: managed-jpa] Unable to build Hibernate SessionFactory
  2. 0

    After the latest envers classloader changes HHH-10365 hibernate is unable to build the SessionFactory for this case: * Entity is audited * Entity has an attribute of a different bundle When @Audited is removed from the entity, the SessionFactory is build properly. Example code to reproduce this issue: https://github.com/fwassmer/hibernate-demos/tree/classloader/hibernate-orm/osgi/managed-jpa Following exception is thrown: {noformat} 2016-06-06T12:44:16,834 | ERROR | pa.managed-jpa]) | 7 - org.apache.felix.configadmin - 1.8.8 | configadmin | [org.osgi.service.cm.ManagedService, id=167, bundle=29/mvn:org.apache.aries.jpa/org.apache.aries.jpa.container/2.3.0]: Unexpected problem updating configuration org.apache.aries.jpa.managed-jpa javax.persistence.PersistenceException: [PersistenceUnit: managed-jpa] Unable to build Hibernate SessionFactory at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:961) [123:org.hibernate.core:5.2.0.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:891) [123:org.hibernate.core:5.2.0.Final] at org.hibernate.osgi.OsgiPersistenceProvider.createContainerEntityManagerFactory(OsgiPersistenceProvider.java:96) [125:org.hibernate.osgi:5.2.0.Final] at org.apache.aries.jpa.container.impl.ManagedEMF.createAndPublishEMF(ManagedEMF.java:129) [29:org.apache.aries.jpa.container:2.3.0] at org.apache.aries.jpa.container.impl.ManagedEMF.updated(ManagedEMF.java:125) [29:org.apache.aries.jpa.container:2.3.0] at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updated(ManagedServiceTracker.java:189) [7:org.apache.felix.configadmin:1.8.8] at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(ManagedServiceTracker.java:152) [7:org.apache.felix.configadmin:1.8.8] at org.apache.felix.cm.impl.helper.ManagedServiceTracker.provideConfiguration(ManagedServiceTracker.java:85) [7:org.apache.felix.configadmin:1.8.8] at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.provide(ConfigurationManager.java:1444) [7:org.apache.felix.configadmin:1.8.8] at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.run(ConfigurationManager.java:1400) [7:org.apache.felix.configadmin:1.8.8] at org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:143) [7:org.apache.felix.configadmin:1.8.8] at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:110) [7:org.apache.felix.configadmin:1.8.8] at java.lang.Thread.run(Thread.java:745) [?:?] Caused by: org.hibernate.MappingException: Unable to instantiate custom type: org.hibernate.type.EnumType at org.hibernate.type.TypeFactory.custom(TypeFactory.java:207) ~[?:?] at org.hibernate.type.TypeFactory.custom(TypeFactory.java:193) ~[?:?] at org.hibernate.type.TypeFactory.byClass(TypeFactory.java:107) ~[?:?] at org.hibernate.type.TypeResolver.heuristicType(TypeResolver.java:112) ~[?:?] at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:401) ~[?:?] at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:383) ~[?:?] at org.hibernate.mapping.Property.isValid(Property.java:226) ~[?:?] at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:595) ~[?:?] at org.hibernate.mapping.RootClass.validate(RootClass.java:265) ~[?:?] at org.hibernate.boot.internal.MetadataImpl.validate(MetadataImpl.java:329) ~[?:?] at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:475) ~[?:?] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:888) ~[?:?] ... 11 more Caused by: org.hibernate.HibernateException: Enum class not found: org.broken.datatype.DataTypeEnum at org.hibernate.type.EnumType.setParameterValues(EnumType.java:108) ~[?:?] at org.hibernate.type.TypeFactory.injectParameters(TypeFactory.java:142) ~[?:?] at org.hibernate.type.TypeFactory.custom(TypeFactory.java:203) ~[?:?] at org.hibernate.type.TypeFactory.custom(TypeFactory.java:193) ~[?:?] at org.hibernate.type.TypeFactory.byClass(TypeFactory.java:107) ~[?:?] at org.hibernate.type.TypeResolver.heuristicType(TypeResolver.java:112) ~[?:?] at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:401) ~[?:?] at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:383) ~[?:?] at org.hibernate.mapping.Property.isValid(Property.java:226) ~[?:?] at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:595) ~[?:?] at org.hibernate.mapping.RootClass.validate(RootClass.java:265) ~[?:?] at org.hibernate.boot.internal.MetadataImpl.validate(MetadataImpl.java:329) ~[?:?] at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:475) ~[?:?] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:888) ~[?:?] ... 11 more Caused by: java.lang.ClassNotFoundException: org.broken.datatype.DataTypeEnum not found by org.hibernate.core [123] at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1574) ~[?:?] at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:79) ~[?:?] at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2018) ~[?:?] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:?] at java.lang.Class.forName0(Native Method) ~[?:?] at java.lang.Class.forName(Class.java:348) ~[?:?] at org.hibernate.internal.util.ReflectHelper.classForName(ReflectHelper.java:151) ~[?:?] at org.hibernate.type.EnumType.setParameterValues(EnumType.java:105) ~[?:?] at org.hibernate.type.TypeFactory.injectParameters(TypeFactory.java:142) ~[?:?] at org.hibernate.type.TypeFactory.custom(TypeFactory.java:203) ~[?:?] at org.hibernate.type.TypeFactory.custom(TypeFactory.java:193) ~[?:?] at org.hibernate.type.TypeFactory.byClass(TypeFactory.java:107) ~[?:?] at org.hibernate.type.TypeResolver.heuristicType(TypeResolver.java:112) ~[?:?] at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:401) ~[?:?] at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:383) ~[?:?] at org.hibernate.mapping.Property.isValid(Property.java:226) ~[?:?] at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:595) ~[?:?] at org.hibernate.mapping.RootClass.validate(RootClass.java:265) ~[?:?] at org.hibernate.boot.internal.MetadataImpl.validate(MetadataImpl.java:329) ~[?:?] at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:475) ~[?:?] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:888) ~[?:?] ... 11 more {noformat} It seems the org.hibernate.core bundle tries to lookup the class DataTypeEnum with the wrong classloader, looking only in it's own bundle and imports, not in the bundle providing the persistence context (managed-jpa in this case, which has the class in it's imports).

    Hibernate JIRA | 6 months ago | Felix Wassmer
    javax.persistence.PersistenceException: [PersistenceUnit: managed-jpa] Unable to build Hibernate SessionFactory
  3. 0

    HELP - org.glassfish.jersey.internal.RuntimeDelegateImpl not found by javax.ws.rs

    apache.org | 1 year ago
    java.lang.RuntimeException: java.lang.ClassNotFoundException: org.glassfish.jersey.internal.RuntimeDelegateImpl not found by javax.ws.rs-api [244]
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    ExtremeTransactions 3.9.5 | Blog | Atomikos

    atomikos.com | 3 months ago
    java.lang.ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder not found by com.atomikos.transactions-osgi [129]
  6. 0

    HSQLDB bundle in felix org.hsqldb.jdbcDriver not found

    Stack Overflow | 4 years ago | Arthur Khusntudinov
    java.lang.ClassNotFoundException: org.hsqldb.jdbcDriver not found by ihtika2.I_InternalFunctions [7]

  1. davidvanlaatum 1 times, last 2 weeks ago
  2. davidvanlaatum 8 times, last 4 months ago
  3. mindenaron 1 times, last 10 months ago
43 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.ClassNotFoundException

    org.broken.datatype.DataTypeEnum not found by org.hibernate.core [123]

    at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation()
  2. Apache Felix Framework
    BundleWiringImpl$BundleClassLoader.loadClass
    1. org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1574)[?:?]
    2. org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:79)[?:?]
    3. org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2018)[?:?]
    3 frames
  3. Java RT
    Class.forName
    1. java.lang.ClassLoader.loadClass(ClassLoader.java:357)[?:?]
    2. java.lang.Class.forName0(Native Method)[?:?]
    3. java.lang.Class.forName(Class.java:348)[?:?]
    3 frames
  4. Hibernate
    RootClass.validate
    1. org.hibernate.internal.util.ReflectHelper.classForName(ReflectHelper.java:151)[?:?]
    2. org.hibernate.type.EnumType.setParameterValues(EnumType.java:105)[?:?]
    3. org.hibernate.type.TypeFactory.injectParameters(TypeFactory.java:142)[?:?]
    4. org.hibernate.type.TypeFactory.custom(TypeFactory.java:203)[?:?]
    5. org.hibernate.type.TypeFactory.custom(TypeFactory.java:193)[?:?]
    6. org.hibernate.type.TypeFactory.byClass(TypeFactory.java:107)[?:?]
    7. org.hibernate.type.TypeResolver.heuristicType(TypeResolver.java:112)[?:?]
    8. org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:401)[?:?]
    9. org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:383)[?:?]
    10. org.hibernate.mapping.Property.isValid(Property.java:226)[?:?]
    11. org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:595)[?:?]
    12. org.hibernate.mapping.RootClass.validate(RootClass.java:265)[?:?]
    12 frames
  5. org.hibernate.boot
    SessionFactoryBuilderImpl.build
    1. org.hibernate.boot.internal.MetadataImpl.validate(MetadataImpl.java:329)[?:?]
    2. org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:475)[?:?]
    2 frames
  6. org.hibernate.jpa
    EntityManagerFactoryBuilderImpl.build
    1. org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:888)[?:?]
    1 frame
  7. org.hibernate.osgi
    OsgiPersistenceProvider.createContainerEntityManagerFactory
    1. org.hibernate.osgi.OsgiPersistenceProvider.createContainerEntityManagerFactory(OsgiPersistenceProvider.java:96)[125:org.hibernate.osgi:5.2.0.Final]
    1 frame
  8. org.apache.aries
    ManagedEMF.updated
    1. org.apache.aries.jpa.container.impl.ManagedEMF.createAndPublishEMF(ManagedEMF.java:129)[29:org.apache.aries.jpa.container:2.3.0]
    2. org.apache.aries.jpa.container.impl.ManagedEMF.updated(ManagedEMF.java:125)[29:org.apache.aries.jpa.container:2.3.0]
    2 frames
  9. Apache Felix Configuration Admin Service
    UpdateThread.run
    1. org.apache.felix.cm.impl.helper.ManagedServiceTracker.updated(ManagedServiceTracker.java:189)[7:org.apache.felix.configadmin:1.8.8]
    2. org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(ManagedServiceTracker.java:152)[7:org.apache.felix.configadmin:1.8.8]
    3. org.apache.felix.cm.impl.helper.ManagedServiceTracker.provideConfiguration(ManagedServiceTracker.java:85)[7:org.apache.felix.configadmin:1.8.8]
    4. org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.provide(ConfigurationManager.java:1444)[7:org.apache.felix.configadmin:1.8.8]
    5. org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.run(ConfigurationManager.java:1400)[7:org.apache.felix.configadmin:1.8.8]
    6. org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:143)[7:org.apache.felix.configadmin:1.8.8]
    7. org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:110)[7:org.apache.felix.configadmin:1.8.8]
    7 frames
  10. Java RT
    Thread.run
    1. java.lang.Thread.run(Thread.java:745)[?:?]
    1 frame