Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to start quarkus due to hibernate-orm datasource related config issue/bug(?) #23563

Closed
syr opened this issue Feb 9, 2022 · 10 comments
Closed
Labels
area/hibernate-orm Hibernate ORM area/persistence OBSOLETE, DO NOT USE

Comments

@syr
Copy link

syr commented Feb 9, 2022

Hello, I am just starting with quarkus and just cannot get it started with two defined datasources (postgres, oracle), configured like
(Referring to https://quarkus.io/guides/datasource#other-databases)

quarkus.datasource.a.db-kind=postgresql
quarkus.datasource.a.jdbc.driver=org.postgresql.Driver
quarkus.datasource.a.jdbc.url=jdbc:postgresql://localhost:5432/a
quarkus.datasource.a.username=docker
quarkus.datasource.a.password=docker
quarkus.hibernate-orm.a.packages=my.package.model.a
quarkus.hibernate-orm.a.datasource=a

quarkus.datasource.b.db-kind=other
quarkus.datasource.b.jdbc.driver=oracle.jdbc.driver.OracleDriver
quarkus.datasource.b.jdbc.url=jdbc:oracle:thin:@****.net:1531:servicename
quarkus.datasource.b.username=docker
quarkus.datasource.b.password=docker
quarkus.hibernate-orm.b.packages=my.package.model.b
quarkus.hibernate-orm.b.dialect=org.hibernate.dialect.OracleDialect
quarkus.hibernate-orm.b.datasource=b

In the stacktrace I have no clue whats wrong, assuming the warnings are not related.
Considering Unable to determine a database type for default datasource I also tried to remove the name 'a' of the postgres datasource to make it the default datasource but it didn't help.
Any ideas?

Connected to the target VM, address: 'localhost:62811', transport: 'socket'
Press [h] for more options>
Tests paused
Press [r] to resume testing, [h] for more options>
Press [r] to resume testing, [o] Toggle test output, [h] for more options>
2022-02-09 19:45:40,266 WARN  [io.qua.dat.dep.dev.DevServicesDatasourceProcessor] (build-16) Unable to determine a database type for default datasource
2022-02-09 19:45:40,270 WARN  [io.qua.hib.orm.dep.HibernateOrmProcessor] (build-25) Could not find a suitable persistence unit for model classes:
	- io.quarkus.hibernate.orm.panache.PanacheEntity
2022-02-09 19:45:40,286 WARN  [io.qua.dat.dep.dev.DevServicesDatasourceProcessor] (build-16) Unable to start devservices for fips as this datasource type (other) does not support devservices
__  ____  __  _____   ___  __ ____  ______ 
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ 
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \   
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/   
2022-02-09 19:45:41,935 WARN  [org.hib.dia.Oracle9Dialect] (Quarkus Main Thread) HHH000063: The Oracle9Dialect dialect has been deprecated; use either Oracle9iDialect or Oracle10gDialect instead
2022-02-09 19:45:41,936 WARN  [org.hib.dia.OracleDialect] (Quarkus Main Thread) HHH000064: The OracleDialect dialect has been deprecated; use Oracle8iDialect instead
2022-02-09 19:45:42,011 WARN  [org.hib.map.RootClass] (Quarkus Main Thread) HHH000038: Composite-id class does not override equals(): my.package.model.b.SessionId
2022-02-09 19:45:42,011 WARN  [org.hib.map.RootClass] (Quarkus Main Thread) HHH000039: Composite-id class does not override hashCode(): my.package.model.b.SessionId
2022-02-09 19:45:42,355 WARN  [io.qua.agr.run.AgroalConnectionConfigurer] (Quarkus Main Thread) Agroal does not support detecting if a connection is still usable after an exception for database kind: other
2022-02-09 19:45:42,756 ERROR [io.qua.run.Application] (Quarkus Main Thread) Failed to start application (with profile dev): java.lang.NullPointerException
	at io.quarkus.hibernate.orm.runtime.FastBootHibernatePersistenceProvider.injectRuntimeConfiguration(FastBootHibernatePersistenceProvider.java:379)
	at io.quarkus.hibernate.orm.runtime.FastBootHibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(FastBootHibernatePersistenceProvider.java:187)
	at io.quarkus.hibernate.orm.runtime.FastBootHibernatePersistenceProvider.createEntityManagerFactory(FastBootHibernatePersistenceProvider.java:65)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:80)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
	at io.quarkus.hibernate.orm.runtime.JPAConfig$LazyPersistenceUnit.get(JPAConfig.java:138)
	at io.quarkus.hibernate.orm.runtime.JPAConfig$1.run(JPAConfig.java:54)
	at java.base/java.lang.Thread.run(Thread.java:829)

2022-02-09 19:45:42,758 INFO  [io.qua.dep.dev.IsolatedDevModeMain] (main) Attempting to start live reload endpoint to recover from previous Quarkus startup failure
Press [space] to restart, [e] to edit command line args (currently ''), [r] to resume testing, [o] Toggle test output, [h] for more options>
2022-02-09 19:45:42,820 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: java.lang.RuntimeException: Failed to start quarkus
	at io.quarkus.dev.appstate.ApplicationStateNotification.waitForApplicationStart(ApplicationStateNotification.java:51)
	at io.quarkus.runner.bootstrap.StartupActionImpl.runMainClass(StartupActionImpl.java:122)
	at io.quarkus.deployment.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:145)
	at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:456)
	at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:67)
	at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:150)
	at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:106)
	at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:132)
	at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:62)
Caused by: java.lang.RuntimeException: Failed to start quarkus
	at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
	at io.quarkus.runtime.Application.start(Application.java:101)
	at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:104)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:67)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:41)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:120)
	at io.quarkus.runner.GeneratedMain.main(Unknown Source)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:103)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
	at io.quarkus.hibernate.orm.runtime.JPAConfig.startAll(JPAConfig.java:68)
	at io.quarkus.hibernate.orm.runtime.JPAConfig_Subclass.startAll$$superforward1(Unknown Source)
	at io.quarkus.hibernate.orm.runtime.JPAConfig_Subclass$$function$$4.apply(Unknown Source)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
	at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:62)
	at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:51)
	at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(Unknown Source)
	at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41)
	at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
	at io.quarkus.hibernate.orm.runtime.JPAConfig_Subclass.startAll(Unknown Source)
	at io.quarkus.hibernate.orm.runtime.HibernateOrmRecorder.startAllPersistenceUnits(HibernateOrmRecorder.java:97)
	at io.quarkus.deployment.steps.HibernateOrmProcessor$startPersistenceUnits1868654632.deploy_0(Unknown Source)
	at io.quarkus.deployment.steps.HibernateOrmProcessor$startPersistenceUnits1868654632.deploy(Unknown Source)
	... 13 more
Caused by: java.lang.NullPointerException
	at io.quarkus.hibernate.orm.runtime.FastBootHibernatePersistenceProvider.injectRuntimeConfiguration(FastBootHibernatePersistenceProvider.java:379)
	at io.quarkus.hibernate.orm.runtime.FastBootHibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(FastBootHibernatePersistenceProvider.java:187)
	at io.quarkus.hibernate.orm.runtime.FastBootHibernatePersistenceProvider.createEntityManagerFactory(FastBootHibernatePersistenceProvider.java:65)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:80)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
	at io.quarkus.hibernate.orm.runtime.JPAConfig$LazyPersistenceUnit.get(JPAConfig.java:138)
	at io.quarkus.hibernate.orm.runtime.JPAConfig$1.run(JPAConfig.java:54)
	... 1 more

2022-02-09 19:45:42,820 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: java.lang.RuntimeException: Failed to start quarkus
	at io.quarkus.dev.appstate.ApplicationStateNotification.waitForApplicationStart(ApplicationStateNotification.java:51)
	at io.quarkus.runner.bootstrap.StartupActionImpl.runMainClass(StartupActionImpl.java:122)
	at io.quarkus.deployment.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:145)
	at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:456)
	at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:67)
	at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:150)
	at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:106)
	at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:132)
	at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:62)
Caused by: java.lang.RuntimeException: Failed to start quarkus
	at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
	at io.quarkus.runtime.Application.start(Application.java:101)
	at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:104)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:67)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:41)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:120)
	at io.quarkus.runner.GeneratedMain.main(Unknown Source)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:103)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
	at io.quarkus.hibernate.orm.runtime.JPAConfig.startAll(JPAConfig.java:68)
	at io.quarkus.hibernate.orm.runtime.JPAConfig_Subclass.startAll$$superforward1(Unknown Source)
	at io.quarkus.hibernate.orm.runtime.JPAConfig_Subclass$$function$$4.apply(Unknown Source)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
	at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:62)
	at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:51)
	at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(Unknown Source)
	at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41)
	at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
	at io.quarkus.hibernate.orm.runtime.JPAConfig_Subclass.startAll(Unknown Source)
	at io.quarkus.hibernate.orm.runtime.HibernateOrmRecorder.startAllPersistenceUnits(HibernateOrmRecorder.java:97)
	at io.quarkus.deployment.steps.HibernateOrmProcessor$startPersistenceUnits1868654632.deploy_0(Unknown Source)
	at io.quarkus.deployment.steps.HibernateOrmProcessor$startPersistenceUnits1868654632.deploy(Unknown Source)
	... 13 more
Caused by: java.lang.NullPointerException
	at io.quarkus.hibernate.orm.runtime.FastBootHibernatePersistenceProvider.injectRuntimeConfiguration(FastBootHibernatePersistenceProvider.java:379)
	at io.quarkus.hibernate.orm.runtime.FastBootHibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(FastBootHibernatePersistenceProvider.java:187)
	at io.quarkus.hibernate.orm.runtime.FastBootHibernatePersistenceProvider.createEntityManagerFactory(FastBootHibernatePersistenceProvider.java:65)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:80)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
	at io.quarkus.hibernate.orm.runtime.JPAConfig$LazyPersistenceUnit.get(JPAConfig.java:138)
	at io.quarkus.hibernate.orm.runtime.JPAConfig$1.run(JPAConfig.java:54)
	... 1 more


@quarkus-bot
Copy link

quarkus-bot bot commented Feb 9, 2022

/cc @Sanne, @gsmet, @yrodiere

@quarkus-bot quarkus-bot bot added area/hibernate-orm Hibernate ORM area/persistence OBSOLETE, DO NOT USE labels Feb 9, 2022
@Foobartender
Copy link
Contributor

You still need a default datasource, i.e. one without a or b.

@yrodiere
Copy link
Member

You still need a default datasource, i.e. one without a or b.

I wonder why, though? IIRC, when it comes to JPA persistence units, the default one is automatically disabled (unless explicitly configured) as soon as there are named persistence units. Can't we do the same for datasources?

On a side note, this NPE is definitely not good user experience, and that at least should be fixed. I'll look into it.

Could someone else more familiar with the agroal/datasource part please look into why we always need a default datasource? And maybe document it, since it seems the user guide doesn't explicitly warn that you always need a default datasource.

@syr
Copy link
Author

syr commented Feb 10, 2022

Thanks for your feedback. As mentioned in the initial post, I already tried after making postgres the default datasource by removing 'a' but still get same stacktrace.

I adapted the application.properties, making postgres default AND also removed the quarkus.hibernate-orm.packages resulting in:

quarkus.datasource.db-kind=postgresql
quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/a
quarkus.datasource.username=docker
quarkus.datasource.password=docker

quarkus.datasource.b.db-kind=other
quarkus.datasource.b.jdbc.driver=oracle.jdbc.driver.OracleDriver
quarkus.datasource.b.jdbc.url=jdbc:oracle:thin:@****.net:1531:servicename
quarkus.datasource.b.username=docker
quarkus.datasource.b.password=docker
quarkus.hibernate-orm.b.dialect=org.hibernate.dialect.OracleDialect

Now quarkus starts up without the mentioned exception, however messes up access by querying tables from datasource b (oracle) using the default datasource (postgres).

So seems the problem is related to quarkus.hibernate-orm.packages.

FYI:

my.package.model.a: contains an @entity class which extends PanacheEntityBase with @table referring to a postgres table
my.package.model.b: contains an @entity class which extends PanacheEntityBase with @table referring to a oracle table

@yrodiere
Copy link
Member

yrodiere commented Feb 10, 2022

however messes up access by querying tables from datasource b (oracle) using the default datasource (postgres).

That's because you didn't assign datasource b to persistence unit b:

quarkus.hibernate-orm.b.datasource=b

EDIT: also, dropping quarkus.hibernate-orm.packages is not a good idea; it serves a purpose and not using it will change the content of your persistence units. Not sure what you're trying to do?

@syr
Copy link
Author

syr commented Feb 10, 2022

@yrodiere I only desparately try to get two datasources plugged to two distinct packages to work. I dont understand what magic is going on and fails with this config. I see no significant difference to the example config from documentation (https://quarkus.io/guides/hibernate-orm#multiple-persistence-units)

I adapted the config to:

quarkus.datasource.db-kind=postgresql
quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/a
quarkus.datasource.username=docker
quarkus.datasource.password=docker
quarkus.hibernate-orm.packages=my.package.model.a

quarkus.datasource.b.db-kind=other
quarkus.datasource.b.jdbc.driver=oracle.jdbc.driver.OracleDriver
quarkus.datasource.b.jdbc.url=jdbc:oracle:thin:@****.net:1531:servicename
quarkus.datasource.b.username=docker
quarkus.datasource.b.password=docker
quarkus.hibernate-orm.b.packages=my.package.model.b
quarkus.hibernate-orm.b.datasource=b
quarkus.hibernate-orm.b.dialect=org.hibernate.dialect.OracleDialect

and get the same stack trace.

What seems also weird, is

2022-02-09 19:45:40,270 WARN  [io.qua.hib.orm.dep.HibernateOrmProcessor] (build-25) Could not find a suitable persistence unit for model classes:
	- io.quarkus.hibernate.orm.panache.PanacheEntity

@yrodiere
Copy link
Member

What seems also weird, is

2022-02-09 19:45:40,270 WARN  [io.qua.hib.orm.dep.HibernateOrmProcessor] (build-25) Could not find a suitable persistence unit for model classes:
	- io.quarkus.hibernate.orm.panache.PanacheEntity

It does seem weird, but I'm not sure it's related. I imagine you have a dependency to panache in your POM, but you're not extending PanacheEntity anywhere? That would explain it.

@syr
Copy link
Author

syr commented Feb 10, 2022

What seems also weird, is

2022-02-09 19:45:40,270 WARN  [io.qua.hib.orm.dep.HibernateOrmProcessor] (build-25) Could not find a suitable persistence unit for model classes:
	- io.quarkus.hibernate.orm.panache.PanacheEntity

It does seem weird, but I'm not sure it's related. I imagine you have a dependency to panache in your POM, but you're not extending PanacheEntity anywhere? That would explain it.

OK then I would ignore it if this is normal. My entities extend PanacheEntityBase because I need custom IDs.

my.package.model.a: contains an entity class which extends PanacheEntityBase with table referring to a postgres table

my.package.model.b: contains an entity class which extends PanacheEntityBase with table referring to a oracle table

@yrodiere
Copy link
Member

Ok, I had a closer look at the stack trace. This is not a configuration problem at all, this is a bug in Quarkus, and it's been solved in #23422, which has merged in Quarkus 2.7.1.Final.

I'll close this ticket as duplicate of #23422. If the problem still occurs with Quarkus 2.7.1.Final, please reopen.

@yrodiere
Copy link
Member

Duplicate of #23422

@yrodiere yrodiere marked this as a duplicate of #23422 Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/hibernate-orm Hibernate ORM area/persistence OBSOLETE, DO NOT USE
Projects
None yet
Development

No branches or pull requests

3 participants