Open xuxianzhang opened 3 years ago
/cc @Sanne, @aguibert, @gavinking, @gsmet
Using both Hibernate ORM and Hibernate Reactive in parallel is not supported at the moment. That's something we need to work on.
Any work on this?
This issue is blocking my workaround for https://github.com/quarkusio/quarkus/issues/19302
Got bit trying to mix these too:
implementation("io.quarkus:quarkus-hibernate-reactive")
implementation("io.quarkus:quarkus-hibernate-reactive-panache")
implementation("io.quarkus:quarkus-hibernate-orm-panache-kotlin")
implementation("io.quarkus:quarkus-jdbc-mysql")
implementation("io.quarkus:quarkus-reactive-mysql-client")
You can't use the hibernate reactive artifacts with panache-kotlin?
I'm running into the same issue after trying to migrate to reactive dependencies. I do not know why this issue occurs. Not using Kotlin.
//implementation 'io.quarkus:quarkus-agroal'
//implementation 'io.quarkus:quarkus-hibernate-orm'
//implementation 'io.quarkus:quarkus-hibernate-orm-panache'
//implementation 'io.quarkus:quarkus-jdbc-postgresql'
implementation 'io.quarkus:quarkus-reactive-pg-client'
implementation "io.quarkus:quarkus-hibernate-envers"
implementation 'io.quarkus:quarkus-hibernate-reactive'
implementation 'io.quarkus:quarkus-hibernate-validator'
implementation 'io.quarkus:quarkus-hibernate-reactive-panache'
... 1 more
Caused by: java.lang.IllegalStateException: Booting an Hibernate Reactive serviceregistry on a non-reactive RecordedState!
at io.quarkus.hibernate.reactive.runtime.boot.registry.PreconfiguredReactiveServiceRegistryBuilder.checkIsReactive(PreconfiguredReactiveServiceRegistryBuilder.java:77)
at io.quarkus.hibernate.reactive.runtime.boot.registry.PreconfiguredReactiveServiceRegistryBuilder.<init>(PreconfiguredReactiveServiceRegistryBuilder.java:67)
at io.quarkus.hibernate.reactive.runtime.FastBootHibernateReactivePersistenceProvider.rewireMetadataAndExtractServiceRegistry(FastBootHibernateReactivePersistenceProvider.java:177)
at io.quarkus.hibernate.reactive.runtime.FastBootHibernateReactivePersistenceProvider.getEntityManagerFactoryBuilderOrNull(FastBootHibernateReactivePersistenceProvider.java:156)
at io.quarkus.hibernate.reactive.runtime.FastBootHibernateReactivePersistenceProvider.createEntityManagerFactory(FastBootHibernateReactivePersistenceProvider.java:82)
... 5 more
Would be really nice to have more telling error messages, especially when dependencies are clashing, like:
"You cannot use dependency xyz when using reactive dependency x"
I'd guess that quarkus-hibernate-envers is not reactive @mklueh. Have you tried removing it?
@kenyee yes I did, nothing changed. I haven't tried the hibernate validation dependency, but I'd guess those basic things should work with reactive as well
you could try dumping dependencies... e.g. "./gradlew dependencies" to see what pulls in the non-reactive hibernate...
@kenyee thanks, I'll try that. Does it have to be a non-reactive Hibernate dependency or could it also be something else?
@mklueh mixing isn't allowed...so remove the thing that's pulling in the non-reactive version...
@kenyee This is the only thing I've found
+--- io.quarkus:quarkus-hibernate-reactive -> 2.6.3.Final
| +--- io.quarkus:quarkus-hibernate-orm:2.6.3.Final
hibernate-orm is a transitive dependency of hibernate reactive
sounds like you're ok then...can you post your full stack trace?
I've excluded the validator dependency too test-wise, without any effect. This is the full stacktrace:
2022-01-25 21:41:51,042 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:149)
at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:105)
at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:145)
at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:63)
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:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:103)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.RuntimeException: javax.persistence.PersistenceException: Unable to build EntityManagerFactory
at io.quarkus.hibernate.orm.runtime.JPAConfig.startAll(JPAConfig.java:72)
at io.quarkus.hibernate.orm.runtime.JPAConfig_Subclass.startAll$$superforward1(Unknown Source)
at io.quarkus.hibernate.orm.runtime.JPAConfig_Subclass$$function$$5.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: javax.persistence.PersistenceException: Unable to build EntityManagerFactory
at io.quarkus.hibernate.reactive.runtime.FastBootHibernateReactivePersistenceProvider.createEntityManagerFactory(FastBootHibernateReactivePersistenceProvider.java:93)
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:149)
at io.quarkus.hibernate.orm.runtime.JPAConfig$1.run(JPAConfig.java:58)
... 1 more
Caused by: java.lang.IllegalStateException: Booting an Hibernate Reactive serviceregistry on a non-reactive RecordedState!
at io.quarkus.hibernate.reactive.runtime.boot.registry.PreconfiguredReactiveServiceRegistryBuilder.checkIsReactive(PreconfiguredReactiveServiceRegistryBuilder.java:77)
at io.quarkus.hibernate.reactive.runtime.boot.registry.PreconfiguredReactiveServiceRegistryBuilder.<init>(PreconfiguredReactiveServiceRegistryBuilder.java:67)
at io.quarkus.hibernate.reactive.runtime.FastBootHibernateReactivePersistenceProvider.rewireMetadataAndExtractServiceRegistry(FastBootHibernateReactivePersistenceProvider.java:177)
at io.quarkus.hibernate.reactive.runtime.FastBootHibernateReactivePersistenceProvider.getEntityManagerFactoryBuilderOrNull(FastBootHibernateReactivePersistenceProvider.java:156)
at io.quarkus.hibernate.reactive.runtime.FastBootHibernateReactivePersistenceProvider.createEntityManagerFactory(FastBootHibernateReactivePersistenceProvider.java:82)
... 5 more
2022-01-25 21:41:51,042 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:149)
at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:105)
at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:145)
at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:63)
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:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:103)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.RuntimeException: javax.persistence.PersistenceException: Unable to build EntityManagerFactory
at io.quarkus.hibernate.orm.runtime.JPAConfig.startAll(JPAConfig.java:72)
at io.quarkus.hibernate.orm.runtime.JPAConfig_Subclass.startAll$$superforward1(Unknown Source)
at io.quarkus.hibernate.orm.runtime.JPAConfig_Subclass$$function$$5.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: javax.persistence.PersistenceException: Unable to build EntityManagerFactory
at io.quarkus.hibernate.reactive.runtime.FastBootHibernateReactivePersistenceProvider.createEntityManagerFactory(FastBootHibernateReactivePersistenceProvider.java:93)
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:149)
at io.quarkus.hibernate.orm.runtime.JPAConfig$1.run(JPAConfig.java:58)
... 1 more
Caused by: java.lang.IllegalStateException: Booting an Hibernate Reactive serviceregistry on a non-reactive RecordedState!
at io.quarkus.hibernate.reactive.runtime.boot.registry.PreconfiguredReactiveServiceRegistryBuilder.checkIsReactive(PreconfiguredReactiveServiceRegistryBuilder.java:77)
at io.quarkus.hibernate.reactive.runtime.boot.registry.PreconfiguredReactiveServiceRegistryBuilder.<init>(PreconfiguredReactiveServiceRegistryBuilder.java:67)
at io.quarkus.hibernate.reactive.runtime.FastBootHibernateReactivePersistenceProvider.rewireMetadataAndExtractServiceRegistry(FastBootHibernateReactivePersistenceProvider.java:177)
at io.quarkus.hibernate.reactive.runtime.FastBootHibernateReactivePersistenceProvider.getEntityManagerFactoryBuilderOrNull(FastBootHibernateReactivePersistenceProvider.java:156)
at io.quarkus.hibernate.reactive.runtime.FastBootHibernateReactivePersistenceProvider.createEntityManagerFactory(FastBootHibernateReactivePersistenceProvider.java:82)
... 5 more
Edit: If it makes any difference, my project is a multi-module Gradle project.
hmm...this still makes it look like you're mixing them: "Caused by: java.lang.IllegalStateException: Booting an Hibernate Reactive serviceregistry on a non-reactive RecordedState! at io.quarkus.hibernate.reactive.runtime.boot.registry.PreconfiguredReactiveServiceRegistryBuilder.checkIsReactive(PreconfiguredReactiveServiceRegistryBuilder.java:77)"
Can you look at the dependencies on all the other modules? Though running dependencies at the top should check all the others too 🤔
@kenyee I ran it on the application level, which includes all sub modules and I've searched through the whole dependency tree.
The hibernate dependencies are included in the root build.gradle and not in the modules directly, so I don't have to change every build.gradle.
Is there a chance to see the specific cause in the logs when changing the log level?
If you could share a reproducer I'd like to have a look. To be clear, mixing is still not expected to work, but it looks like we should at very least improve the error messages or the diagnosticts to figure out what's happening in this case.
It turned out I had removed the Hibernate dependencies, but kept the JDBC dependency
implementation 'io.quarkus:quarkus-jdbc-postgresql'
I was also running into this
Caused by: io.quarkus.runtime.configuration.ConfigurationException: Unable to find a JDBC driver corresponding to the database kind 'postgresql' for the default datasource. Either provide a suitable JDBC driver extension, define the driver manually, or disable the JDBC datasource by adding 'quarkus.datasource.jdbc=false' to your configuration if you don't need it.
at io.quarkus.agroal.deployment.AgroalProcessor.resolveDriver(AgroalProcessor.java:331)
at io.quarkus.agroal.deployment.AgroalProcessor.getAggregatedConfigBuildItems(AgroalProcessor.java:277)
at io.quarkus.agroal.deployment.AgroalProcessor.build(AgroalProcessor.java:82)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:887)
at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
at java.base/java.lang.Thread.run(Thread.java:833)
at org.jboss.threads.JBossThread.run(JBossThread.java:501)
as Quarkus seems to be still sensitive to the non-reactive properties and I had the db kind set quarkus.datasource.db-kind=postgresql
.
I didn't know that the jdbc dependencies would also not be allowed together with Hibernate Reactive.
Thanks for your help.
@mklueh did you have to remove that property to fix that error? I tried converting to reactive-hibernate and reverted because I hit that error and couldn't find out why Agroal was complaining about it despite not having a non-reactive JDBC driver...
@kenyee yes, this helps, but also setting quarkus.datasource.jdbc=false
.
This means (pls correct me if I'm wrong), when you can't use JDBC together with reactive libraries, you cannot use the EntityManager, as it relies on JDBC. Meaning I have to migrate my EntityManager-based queries now to something else, that is provided by reactive libraries, ex.: io.quarkus:quarkus-reactive-pg-client
I was thinking, that one could migrate gradually to reactive, and leave some endpoints non-reactive
Edit: I fail to get io.quarkus:quarkus-reactive-pg-client
working.
According to the docs, I need the config property `` again
https://quarkus.io/guides/reactive-sql-clients#configuring
Then I'm getting the error again, and including the JDBC dependency leads to the first error again.
Unable to find a JDBC driver corresponding to the database kind 'postgresql' for the default datasource. Either provide a suitable JDBC driver extension, define the driver manually, or disable the JDBC datasource by adding 'quarkus.datasource.jdbc=false' to your configuration if you don't need it.
Edit: Got the pg-client now working
EntityManager does not work without JDBC, but I'm okay with that. Gives:
java.sql.SQLException: Not using JDBC
at org.hibernate.reactive.provider.service.NoJdbcConnectionProvider.getConnection(NoJdbcConnectionProvider.java:25)
at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:38)
at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:108)
at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:138)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:50)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2122)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2059)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2037)
at org.hibernate.loader.Loader.doQuery(Loader.java:956)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:357)
at org.hibernate.loader.Loader.doList(Loader.java:2868)
at org.hibernate.loader.Loader.doList(Loader.java:2850)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2682)
at org.hibernate.loader.Loader.list(Loader.java:2677)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:338)
at org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:2181)
at org.hibernate.internal.AbstractSharedSessionContract.list(AbstractSharedSessionContract.java:1204)
at org.hibernate.query.internal.NativeQueryImpl.doList(NativeQueryImpl.java:177)
at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1617)
at org.hibernate.query.Query.getResultList(Query.java:165)
at com.launchbase.observatorium.TestResource.getEntityManager(TestResource.java:46)
at com.launchbase.observatorium.TestResource_Subclass.getEntityManager$$superforward1(Unknown Source)
at com.launchbase.observatorium.TestResource_Subclass$$function$$6.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:49)
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.proceed(AroundInvokeInvocationContext.java:50)
at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.invokeInOurTx(TransactionalInterceptorBase.java:132)
at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.invokeInOurTx(TransactionalInterceptorBase.java:103)
at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired.doIntercept(TransactionalInterceptorRequired.java:38)
at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.intercept(TransactionalInterceptorBase.java:57)
at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired.intercept(TransactionalInterceptorRequired.java:32)
at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired_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 com.launchbase.observatorium.TestResource_Subclass.getEntityManager(Unknown Source)
at com.launchbase.observatorium.TestResource_ClientProxy.getEntityManager(Unknown Source)
at com.launchbase.observatorium.TestResource$quarkusrestinvoker$getEntityManager_1875f2bed1152c6f0ff0a4c726b0cefc04e268dd.invoke(Unknown Source)
at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:7)
at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:141)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder$13.runWith(VertxCoreRecorder.java:543)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:833)
Resulted in: org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99)
at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:111)
... 51 more
Resulted in: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154)
at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1626)
... 32 more
pg-client works perfectly fine.
What I did now:
one could migrate gradually to reactive, and leave some endpoints non-reactive
I don't think you can do that w/o creating two microservices....the JDBC and reactive libraries seem to conflict. That means no EntityManager as well...
one could migrate gradually to reactive, and leave some endpoints non-reactive
I don't think you can do that w/o creating two microservices....the JDBC and reactive libraries seem to conflict. That means no EntityManager as well...
@kenyee If I understand this right, I cannot use a hibernate reactive datasource and a non-reactive datasource in the same app right ? I just hit the wall for last two days trying to figure this out.
I have got an app which uses hibernate orm reactive for postgresql. I got a requirement in the same app to pull some data from DB2. Started with db2-reactive and found there is an open issue with that (https://github.com/eclipse-vertx/vertx-sql-client/issues/1131). So moved to plain non-reactive JDBC for DB2 but now hibernate ORM fails to pick the default datasource :(.
[error]: Build step io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor#configurationDescriptorBuilding threw an exception: io.quarkus.runtime.configuration.Configuration
Exception: Model classes are defined for the default persistence unit, but no default datasource was found. The default EntityManagerFactory will not be created. To solve this, configu
re the default datasource. Refer to https://quarkus.io/guides/datasource for guidance.
I guess I will have to write another service to handle this situation now.
@yesvike yes...see 2nd comment above. For your case, that other bug is blocking your usage of db2-reactive so you'll need another service...
@yesvike yes...see 2nd comment above. For your case, that other bug is blocking your usage of db2-reactive so you'll need another service...
@kenyee before I give up this just wanted to make sure that a hibernate orm reactive data source and plain jdbc data source (no hibernate orm also here) cannot exist together right. I just want to make sure that you did not think the second is non reactive hibernate orm. Second one actually plain jdbc. Thanks.
@yesvike: What's interesting is if you dump hibernate-reactive's dependencies, it includes the plain JDBC one. So if you're going to do raw JDBC using e.g. Jooby or something, then I think you'll be ok....
@yesvike: What's interesting is if you dump hibernate-reactive's dependencies, it includes the plain JDBC one. So if you're going to do raw JDBC using e.g. Jooby or something, then I think you'll be ok....
Thanks Kenyee for your responses. I cannot dump the hibernate-reactive dependencies in the existing code. Please elaborate on second line. Are you suggesting to use any other Java datasource connection pool mechanism like Hikari ?
./gradlew dependencies will show you the hierarchy of dependencies (there's a maven equivalent)
I think using the regular JDBC driver dependency should be ok...you just can't mix hibernate reactive/non-reactive...
@kenyee
That's where I have the problem. Here is my build.gradle
dependencies {
implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
implementation 'io.quarkus:quarkus-hibernate-reactive'
implementation 'io.quarkus:quarkus-reactive-pg-client'
implementation 'io.quarkus:quarkus-jdbc-db2'
implementation 'io.quarkus:quarkus-agroal'
implementation 'io.quarkus:quarkus-arc'
implementation 'io.quarkus:quarkus-resteasy'
testImplementation 'io.quarkus:quarkus-junit5'
testImplementation 'io.rest-assured:rest-assured'
}
application.properties
quarkus.datasource.db-kind=postgresql
quarkus.datasource.jdbc=false
quarkus.datasource.reactive.url=****
quarkus.datasource.username=***
quarkus.datasource.password=***
quarkus.datasource.DB2.db-kind=db2
quarkus.datasource.DB2.jdbc.url=***
quarkus.datasource.DB2.username=***
quarkus.datasource.DB2.password=***
I was trying to use hibernate reactive for Postgres and plain JDBC for Db2. With this Hibernate reactive ORM is not able to pick the default data source and throws error.
Exception: Model classes are defined for the default persistence unit, but no default datasource was found. The default EntityManagerFactory will not be created. To solve this, configu
re the default datasource. Refer to https://quarkus.io/guides/datasource for guidance.
at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.handleHibernateORMWithNoPersistenceXml(HibernateOrmProcessor.java:932)
at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.configurationDescriptorBuilding(HibernateOrmProcessor.java:420)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:882)
at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
at java.base/java.lang.Thread.run(Thread.java:833)
at org.jboss.threads.JBossThread.run(JBossThread.java:501)```
I'm getting the same error but in a different use case: I'm using reactive hibernate with panache and I now also need to add a JDBC config store using Quarkus JDBC Config (https://quarkiverse.github.io/quarkiverse-docs/quarkus-config-extensions/dev/jdbc.html)
Caused by: java.lang.IllegalStateException: Booting an Hibernate Reactive serviceregistry on a non-reactive RecordedState!
How can I fix this? Thanks.
FWIW, I stopped using Hibernate Reactive. Seems like it's a good idea in isolation, but it causes too many incompatibility quirks...
disabling default jdbc will help the system to focus on reactive configuration.
Here is sample configuration yml data
quarkus.liquibase.migrate-at-start=false
quarkus.liquibase.change-log: db/changelog/master.xml
quarkus.datasource.db-kind=postgresql
quarkus.datasource.username=${DATASOURCE_USERNAME:user}
quarkus.datasource.password=${DATASOURCE_PASSWORD:pwd}
quarkus.datasource.jdbc= false
quarkus.datasource.url=jdbc:postgresql://${DATASOURCE_HOST:localhost}:${DATASOURCE_PORT:5432}/${DATASOURCE_SCHEMA:database_schema}
quarkus.datasource.validation-query-sql=SELECT 1
quarkus.datasource.reactive.url=vertx-reactive:postgresql://${DATASOURCE_HOST:localhost}:${DATASOURCE_PORT:5432}/${DATASOURCE_SCHEMA:database_schema}
Has there been any traction on this yet? I've recently got a requirement to use Quartz in my reactive application and need the JDBC jobstore as this will be deployed on a clustered environment.
I'm also curious about this. Should we be expecting at some point down the road, to be able to successfully mix reactive and jdbc datasources?
Right now we can not use quarkus-quartz
or quarkus-liquibase
in the same application as quarkus-hibernate-reactive-panache
Should we be expecting at some point down the road, to be able to successfully mix reactive and jdbc datasources?
Eventually yes of course. In this area unfortunately changes need to be done in this order:
For these reasons I'm not working on the current Hibernate Reactive extension. N.B. the above tasks are big but they are mostly complete now, except the last one - so I don't expect this will take ages yet.
There's no way to include a JDBC datasource at the same time as a reactive one.
I'm not aware of that being a limitation - as long as you don't expect to use both flavours of Hibernate you should be able to define as many datasources as you like, and of different types. I'd suggest please ask on zulip or open a separate issue.
@Sanne @yrodiere Is mixing reactive and JDBC resources on the roadmap now that Quarkus 3 has released?
I can't speak for Sanne, but as far as I'm concerned it's not so much "on the roadmap" as "something that we'd like to do at some point and that should be possible". Basically it'll happen when we have the time to work on it or if someone else contributes it.
A contribution for a prerequisite of such a feature was started in #33790, but it seems stalled as the review comments haven't been addressed. Feel free to take over and send your own rebased and fixed version of that PR if you're interested :)
Is this still an open issue in Quarkus 3? So an app cannot have a reactive and non-reactive datasource? I am trying to use the same DB for both reactive and non-reactive:
quarkus.datasource.db-kind= mysql quarkus.datasource.username= ${DB_USER} quarkus.datasource.password= ${DB_PWD} quarkus.datasource.reactive.url= ${DB_URL} quarkus.datasource.jdbc.url= jdbc:${DB_URL}
But when trying to use a orm panache repository I get the error: java.lang.IllegalStateException: The named datasource 'default-reactive' has not been properly configured. See https://quarkus.io/guides/datasource#multiple-datasources for information on how to do that.
The documentation states that a datasource can be both reactive and non-reactive.
Is this still an open issue in Quarkus 3?
Yes, as you can see.
So an app cannot have a reactive and non-reactive datasource?
An app cannot use both Hibernate ORM and Hibernate Reactive together at the moment.
An app can have a reactive and a non-reactive datasource, provided you only use Hibernate ORM, or only Hibernate Reactive, or neither. And this limitation will stay until this issue gets fixed.
java.lang.IllegalStateException: The named datasource 'default-reactive' has not been properly configured. See https://quarkus.io/guides/datasource#multiple-datasources for information on how to do that.
I'd need the full stacktrace to say for sure, but from what I can this exception is thrown by quarkus-hibernate-orm-panache
, whereas the name of your persistence unit suggests you're using with Hibernate Reactive. This won't work, as explained above.
If you want to use Hibernate Reactive, replace your dependency to quarkus-hibernate-orm-panache
with quarkus-hibernate-reactive-panache
.
If you want to use Hibernate ORM, remove your dependency to quarkus-hibernate-reactive
.
If you want to use both, that's not possible until this issue gets fixed.
Any progress on this issue?
Is this still an open issue in Quarkus 3?
Yes, as you can see.
Describe the bug when i boot both hibernate-reactive and hibernate-orm in my own project it throw an IllegalStateException and Quarkus startup failure
My application.yaml:
I think it's probably because a private method checkIsReactive in PreconfiguredReactiveServiceRegistryBuilder.class . This inspection is not supposed to be here. It should be put in FastBootHibernateReactivePersistenceProvider.getEntityManagerFactoryBuilderOrNull where the RecordedState be created at.
This is more in keeping with the original purpose of the method getEntityManagerFactoryBuilderOrNull