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

Hibernate ORM and Hibernate Reactive cannot be used in the same application #13425

Open
xuxianzhang opened this issue Nov 23, 2020 · 41 comments · May be fixed by #44473
Open

Hibernate ORM and Hibernate Reactive cannot be used in the same application #13425

xuxianzhang opened this issue Nov 23, 2020 · 41 comments · May be fixed by #44473
Labels
area/hibernate-orm Hibernate ORM area/hibernate-reactive Hibernate Reactive area/persistence OBSOLETE, DO NOT USE kind/bug Something isn't working

Comments

@xuxianzhang
Copy link

xuxianzhang commented Nov 23, 2020

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:

quarkus:
  datasource:
    jdbc:
      url: ${JDBC_DATABASE_URL:jdbc:mysql://mysql:3306/temple}
    reactive:
      url: ${DATABASE_URL:mysql://mysql:3306/temple}

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.

           RecordedState recordedState = PersistenceUnitsHolder.getRecordedState(persistenceUnitName);
           if(!recordedState.isReactive()){
                log.debug("An Hibernate Reactive serviceregistry can't boot on a non-reactive RecordedState!");
                continue;
           }


            final PrevalidatedQuarkusMetadata metadata = recordedState.getMetadata();
            final BuildTimeSettings buildTimeSettings = recordedState.getBuildTimeSettings();
            final IntegrationSettings integrationSettings = recordedState.getIntegrationSettings();
            RuntimeSettings.Builder runtimeSettingsBuilder = new RuntimeSettings.Builder(buildTimeSettings,
                    integrationSettings);

This is more in keeping with the original purpose of the method getEntityManagerFactoryBuilderOrNull

@xuxianzhang xuxianzhang added the kind/bug Something isn't working label Nov 23, 2020
@ghost ghost added area/hibernate-orm Hibernate ORM area/hibernate-reactive Hibernate Reactive area/persistence OBSOLETE, DO NOT USE labels Nov 23, 2020
@ghost
Copy link

ghost commented Nov 23, 2020

/cc @Sanne, @aguibert, @gavinking, @gsmet

@gsmet
Copy link
Member

gsmet commented Nov 24, 2020

Using both Hibernate ORM and Hibernate Reactive in parallel is not supported at the moment. That's something we need to work on.

@JWood48
Copy link

JWood48 commented Aug 10, 2021

Any work on this?

@MartinX3
Copy link

MartinX3 commented Nov 7, 2021

This issue is blocking my workaround for #19302

@kenyee
Copy link

kenyee commented Jan 22, 2022

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?

@mklueh
Copy link
Contributor

mklueh commented Jan 25, 2022

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"

@kenyee
Copy link

kenyee commented Jan 25, 2022

I'd guess that quarkus-hibernate-envers is not reactive @mklueh. Have you tried removing it?

@mklueh
Copy link
Contributor

mklueh commented Jan 25, 2022

@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

@kenyee
Copy link

kenyee commented Jan 25, 2022

you could try dumping dependencies... e.g. "./gradlew dependencies" to see what pulls in the non-reactive hibernate...

@mklueh
Copy link
Contributor

mklueh commented Jan 25, 2022

@kenyee thanks, I'll try that. Does it have to be a non-reactive Hibernate dependency or could it also be something else?

@kenyee
Copy link

kenyee commented Jan 25, 2022

@mklueh mixing isn't allowed...so remove the thing that's pulling in the non-reactive version...

@mklueh
Copy link
Contributor

mklueh commented Jan 25, 2022

@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

@kenyee
Copy link

kenyee commented Jan 25, 2022

sounds like you're ok then...can you post your full stack trace?

@mklueh
Copy link
Contributor

mklueh commented Jan 25, 2022

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.

@kenyee
Copy link

kenyee commented Jan 25, 2022

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 🤔

@mklueh
Copy link
Contributor

mklueh commented Jan 26, 2022

@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?

@Sanne
Copy link
Member

Sanne commented Jan 26, 2022

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.

@mklueh
Copy link
Contributor

mklueh commented Jan 26, 2022

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.

@kenyee
Copy link

kenyee commented Jan 26, 2022

@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...

@mklueh
Copy link
Contributor

mklueh commented Jan 26, 2022

@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:

  1. Removing implementation 'io.quarkus:quarkus-jdbc-postgresql'
  2. Removing quarkus.datasource.jdbc.url
  3. Adding quarkus.datasource.jdbc=false
  4. Adding quarkus.datasource.db-kind=postgresql

@kenyee
Copy link

kenyee commented Jan 26, 2022

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...

@yesvike
Copy link

yesvike commented Mar 15, 2022

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 (eclipse-vertx/vertx-sql-client#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.

@kenyee
Copy link

kenyee commented Mar 15, 2022

@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
Copy link

yesvike commented Mar 15, 2022

@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.

@kenyee
Copy link

kenyee commented Mar 15, 2022

@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....

@spieps
Copy link

spieps commented Aug 2, 2023

@Sanne @yrodiere Is mixing reactive and JDBC resources on the roadmap now that Quarkus 3 has released?

@yrodiere
Copy link
Member

yrodiere commented Aug 2, 2023

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 :)

@benjes
Copy link

benjes commented Jun 17, 2024

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.

@yrodiere
Copy link
Member

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.

@sdlzhd
Copy link

sdlzhd commented Jul 23, 2024

Any progress on this issue?

@yrodiere
Copy link
Member

Is this still an open issue in Quarkus 3?

Yes, as you can see.

@yrodiere yrodiere mentioned this issue Feb 5, 2025
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/hibernate-reactive Hibernate Reactive area/persistence OBSOLETE, DO NOT USE kind/bug Something isn't working
Projects
None yet