Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
jpa-2.3.0
-
None
-
None
-
Linux; jdk18, Felix
Description
Hi !!
I was applying Christian Schneider example of Declarative services with JPA (example available on github at https://github.com/cschneider/Karaf-Tutorial/blob/master/tasklist-ds) and found a problem with hibernate 5.1 and a oracle datasource (I'm using pax-jdbc with dbcp2 pool).
I'm getting a NPE in hibernate as show bellow. Since this was blocking me I tracked the issue and apparently found the cause.
The culprit is on the following class https://github.com/pferraro/hibernate-core/blob/master/hibernate-core/src/main/java/org/hibernate/hql/spi/id/IdTableHelper.java at line 77
Statement statement = connection.createStatement();
The line above returns null which causes a NPE at line 91 which issues the following code statement:
statement.close();
To correct this I've changed https://github.com/ivoleitao/aries/blob/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/DummyDataSource.java
And added the following check on the method proxyClasses
if (type == Statement.class) {
return createProxy(classLoader, Statement.class);
}
This fixed this issue (the exception does not appear anymore)
STACKTRACE
javax.persistence.PersistenceException: [PersistenceUnit: sso] Unable to build Hibernate SessionFactory
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:954)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:884)
at org.hibernate.osgi.OsgiPersistenceProvider.createContainerEntityManagerFactory(OsgiPersistenceProvider.java:95)
at org.apache.aries.jpa.container.impl.PersistenceProviderTracker.createAndCloseDummyEMF(PersistenceProviderTracker.java:105)
at org.apache.aries.jpa.container.impl.PersistenceProviderTracker.addingService(PersistenceProviderTracker.java:85)
at org.apache.aries.jpa.container.impl.PersistenceProviderTracker.addingService(PersistenceProviderTracker.java:44)
at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:941)
at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:870)
at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
at org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:183)
at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:318)
at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:261)
at org.apache.aries.jpa.container.impl.PersistenceBundleTracker.trackProvider(PersistenceBundleTracker.java:106)
at org.apache.aries.jpa.container.impl.PersistenceBundleTracker.findPersistenceUnits(PersistenceBundleTracker.java:90)
at org.apache.aries.jpa.container.impl.PersistenceBundleTracker.addingBundle(PersistenceBundleTracker.java:69)
at org.apache.aries.jpa.container.impl.PersistenceBundleTracker.addingBundle(PersistenceBundleTracker.java:40)
at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:469)
at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:415)
at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)
at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444)
at org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:916)
at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:835)
at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:517)
at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4541)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:2216)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2144)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998)
at aQute.launcher.Launcher.update(Launcher.java:502)
at aQute.launcher.Launcher.activate(Launcher.java:400)
at aQute.launcher.Launcher.run(Launcher.java:283)
at aQute.launcher.Launcher.main(Launcher.java:133)
Caused by: java.lang.NullPointerException: null
at org.hibernate.hql.spi.id.IdTableHelper.executeIdTableCreationStatements(IdTableHelper.java:91)
at org.hibernate.hql.spi.id.global.GlobalTemporaryTableBulkIdStrategy.finishPreparation(GlobalTemporaryTableBulkIdStrategy.java:125)
at org.hibernate.hql.spi.id.global.GlobalTemporaryTableBulkIdStrategy.finishPreparation(GlobalTemporaryTableBulkIdStrategy.java:42)
at org.hibernate.hql.spi.id.AbstractMultiTableBulkIdStrategyImpl.prepare(AbstractMultiTableBulkIdStrategyImpl.java:88)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:451)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:465)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:881)
... 30 common frames omitted