quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.37k stars 2.56k forks source link

Hibernate Reactive error unclear when starting without a database driver #27620

Open FroMage opened 1 year ago

FroMage commented 1 year ago

Description

When I create a Quarkus project using Hibernate ORM with an entity but without a database driver, I get the following error at startup:

io.quarkus.runtime.configuration.ConfigurationException: 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, configure the default datasource. Refer to https://quarkus.io/guides/datasource for guidance.
Yoann Rodière: That looks like a different issue though; reactive is saying there's no persistence unit (or more than one, if that's even possible), while ORM is saying there's no datasource.

When I try the same with Hibernate Reactive I get the following messages, but startup is not interrupted and my application then gets NPEs because I have no session:

2022-08-31 10:38:45,365 WARN  [io.qua.hib.rea.dep.HibernateReactiveProcessor] (build-51) Skipping registration of ReactiveSessionFactoryProducer and ReactiveSessionProducer because exactly one persistence unit is required for their registration
2022-08-31 10:38:45,373 WARN  [io.qua.dat.dep.dev.DevServicesDatasourceProcessor] (build-42) Unable to determine a database type for default datasource

It would be nice if the error was consistent and told the users that they need a DB driver and where to get one.

Attached: reproducers for both ORM and HR. Just start the apps with mvn clean quarkus:dev

hibernate-reactive-no-driver.zip

Implementation ideas

No response

quarkus-bot[bot] commented 1 year ago

/cc @DavideD, @Sanne, @gavinking

gavinking commented 1 year ago

/cc @DavideD, @Sanne, @gavinking

Looks like one for @Sanne, really.

Sanne commented 1 year ago

I admit there's many things that could be more helpul in how HR and Quarkus are integrated, but we need to finish the upgrade to ORM6 first, then separate the HR extensions from the ORM one. They are too intertwined today and that's not helping.

geoand commented 1 year ago

Is this still an issue with ORM 6.x and HR 2.x?

Sanne commented 1 year ago

The two extensions are still heavily intertwined, as we didn't have time to work on that. But I assume the extensions will "stabilize" after #31974 and then it's finally a good time to rewrite the HR extension to be independent.

geoand commented 1 year ago

If you think that I can help with this (post Quarkus 3.0), feel free to reach out :)

Sanne commented 1 year ago

@geoand you certainly can :) The process in theory is simple:

  1. move all the code that should be shared to a different module
  2. avoid the HR extension to depend on the ORM extension
  3. simplify the HR (and ORM) extension bootstrap as they wouldn't need to try track/guess which "mode" is to be booted
  4. solve issues like this one, as it should be straight forward to figure the right driver is missing at that point
geoand commented 1 year ago

Sounds easy 😆 😆 😆

geoand commented 1 year ago

Jokes aside, if no one picks that up post Quarkus 3.0, I will.