Uploaded image for project: 'Aries'
  1. Aries
  2. ARIES-2159

Cannot obtain connection from DummyDataSource

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • JPA
    • None
    • Apache Karaf 4.4.6, openjdk 21, Postgresql 17 , Aries JPA 2.7.3, Hibernate 5.6.15

    Description

      I can see this exception for every bundle that contains persistence unit:

      2024-10-30T19:55:21,384 | INFO  | features-3-thread-1 | PersistenceBundleTracker         | 177 - org.apache.aries.jpa.container - 2.7.3 | Found persistence unit chronos-i18n in bundle tech.pantheon.chronos.i18n.impl with provider org.hibernate.jpa.HibernatePersistenceProvider.
      2024-10-30T19:55:21,384 | INFO  | features-3-thread-1 | PersistenceProviderTracker       | 177 - org.apache.aries.jpa.container - 2.7.3 | Found provider for chronos-i18n org.hibernate.jpa.HibernatePersistenceProvider
      2024-10-30T19:55:21,384 | INFO  | features-3-thread-1 | LogHelper                        | 245 - org.hibernate.orm.core - 5.6.15.Final | HHH000204: Processing PersistenceUnitInfo [name: chronos-i18n]
      2024-10-30T19:55:21,385 | INFO  | features-3-thread-1 | EnversServiceImpl                | 246 - org.hibernate.orm.envers - 5.6.15.Final | Envers integration enabled? : true
      2024-10-30T19:55:21,458 | INFO  | features-3-thread-1 | Dialect                          | 245 - org.hibernate.orm.core - 5.6.15.Final | HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL10Dialect
      2024-10-30T19:55:21,458 | WARN  | features-3-thread-1 | JdbcEnvironmentInitiator         | 245 - org.hibernate.orm.core - 5.6.15.Final | HHH000342: Could not obtain connection to query metadata
      java.lang.NullPointerException: Cannot invoke "java.sql.Connection.getCatalog()" because the return value of "java.sql.DatabaseMetaData.getConnection()" is null
          at org.hibernate.engine.jdbc.env.internal.ExtractedDatabaseMetaDataImpl$Builder.apply(ExtractedDatabaseMetaDataImpl.java:184) ~[?:?]
          at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentImpl.<init>(JdbcEnvironmentImpl.java:272) ~[?:?]
          at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:114) ~[?:?]
          at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) ~[?:?]
          at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:101) ~[?:?]
          at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:272) ~[?:?]
          at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:246) ~[?:?]
          at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:223) ~[?:?]
          at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:175) ~[?:?]
          at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:295) ~[?:?]
          at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:252) ~[?:?]
          at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:223) ~[?:?]
          at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:173) ~[?:?]
          at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:127) ~[?:?]
          at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1460) ~[?:?]
          at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1494) ~[?:?]
          at org.hibernate.osgi.OsgiPersistenceProvider.createContainerEntityManagerFactory(OsgiPersistenceProvider.java:100) ~[?:?]
          at org.apache.aries.jpa.container.impl.PersistenceProviderTracker.createAndCloseDummyEMF(PersistenceProviderTracker.java:105) ~[?:?]
          at org.apache.aries.jpa.container.impl.PersistenceProviderTracker.addingService(PersistenceProviderTracker.java:86) ~[?:?]
          at org.apache.aries.jpa.container.impl.PersistenceProviderTracker.addingService(PersistenceProviderTracker.java:44) ~[?:?]
          at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:943) ~[osgi.core-8.0.0.jar:?]
          at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:871) ~[osgi.core-8.0.0.jar:?]
          at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) ~[osgi.core-8.0.0.jar:?]
          at org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:183) ~[osgi.core-8.0.0.jar:?]
          at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:321) ~[osgi.core-8.0.0.jar:?]
          at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:264) ~[osgi.core-8.0.0.jar:?]
          at org.apache.aries.jpa.container.impl.PersistenceBundleTracker.trackProvider(PersistenceBundleTracker.java:229) ~[?:?]
          at org.apache.aries.jpa.container.impl.PersistenceBundleTracker.findPersistenceUnits(PersistenceBundleTracker.java:213) ~[?:?]
          at org.apache.aries.jpa.container.impl.PersistenceBundleTracker.addingBundle(PersistenceBundleTracker.java:98) ~[?:?]
          at org.apache.aries.jpa.container.impl.PersistenceBundleTracker.addingBundle(PersistenceBundleTracker.java:44) ~[?:?]
          at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:475) ~[osgi.core-8.0.0.jar:?]
          at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:420) ~[osgi.core-8.0.0.jar:?]
          at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) ~[osgi.core-8.0.0.jar:?]
          at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229) ~[osgi.core-8.0.0.jar:?]
          at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:450) ~[osgi.core-8.0.0.jar:?]
          at org.apache.felix.framework.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:915) ~[?:?]
          at org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:834) ~[?:?]
          at org.apache.felix.framework.EventDispatcher.fireBundleEvent(EventDispatcher.java:516) ~[?:?]
          at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4847) ~[?:?]
          at org.apache.felix.framework.Felix.activateBundle(Felix.java:2420) ~[?:?]
          at org.apache.felix.framework.Felix.startBundle(Felix.java:2335) ~[?:?]
          at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:1006) ~[?:?]
          at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:992) ~[?:?]
          at org.apache.karaf.features.internal.service.BundleInstallSupportImpl.startBundle(BundleInstallSupportImpl.java:165) ~[?:?] 

      There isn't any problem with functionality but this error in log is confusing for QA team. During debugging this problem I found out that there is two-steps procedure how a bundle with persistence unit is processed. At the first step Aries JPA doesn't use a real data source but DummyDataSource.  Real DataSource is used later. This worked correctly with an old version of Hibernate but probably a newer version of Hibernate changed a way how to obtain dialect/metadata. Now there is a null pointer exception from this code (ExtractedDatabaseMetaDataImpl.java)

      public Builder apply(DatabaseMetaData databaseMetaData) throws SQLException {
                  connectionCatalogName = databaseMetaData.getConnection().getCatalog(); <-- NPE
                  // NOTE : databaseMetaData.getConnection().getSchema() would require java 1.7 as baseline
                  supportsRefCursors = StandardRefCursorSupport.supportsRefCursors( databaseMetaData ); 

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jherkel Jakub Herkel
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: