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

Configuration ignored when using config maps and the prefix conflicts with a "static" config group #38321

Closed
yrodiere opened this issue Jan 22, 2024 · 2 comments · Fixed by #38731
Labels
area/config kind/bug Something isn't working
Milestone

Comments

@yrodiere
Copy link
Member

yrodiere commented Jan 22, 2024

Describe the bug

See https://stackoverflow.com/questions/77842431/quarkus-unable-to-name-a-datasource-query

Essentially:

  • quarkus.hibernate-orm.query.* properties exist in the Hibernate ORM extension; there is a config group called query.
  • quarkus.hibernate-orm is also a configuration map, so quarkus.hibernate.orm."persistence-uni-name".* exists to, and quarkus.hibernate-orm.query.* could be interpreted as "configuration for the persistence unit named query".
  • There is, however, little to no overlap between those two possible meanings: the * in the patterns above will rarely, if ever, be the same.
  • Nevertheless, our config seems to always assume that a property starting with quarkus.hibernate-orm.query.* has the first meaning, regardless of what's in *, leading to that configuration property being ignored, because it doesn't matched any config mapping.

Expected behavior

I'd expect quarkus.hibernate-orm.query.datasource to be interpreted as "the datasource for the persistence unit named query" rather than "the datasource config property for the query config group, since only the former actually makes sense and has a matching config mapping.

Actual behavior

quarkus.hibernate-orm.query.datasource is interpreted as "the datasource config property for the query config group, which doesn't make sense.

How to Reproduce?

Copied from https://stackoverflow.com/questions/77842431/quarkus-unable-to-name-a-datasource-query

Checking out the quickstart from here https://github.com/quarkusio/quarkus-quickstarts.git

On hibernate-orm-panache-quickstart: Edit the application.properties with this content:

quarkus.datasource.query.db-kind=postgresql

quarkus.hibernate-orm.query.datasource=query
quarkus.hibernate-orm.query.packages=org.acme.hibernate.orm.panache.entity,org.acme.hibernate.orm.panache.repository
quarkus.hibernate-orm.query.database.generation=drop-and-create
quarkus.hibernate-orm.query.log.sql=true
quarkus.hibernate-orm.query.sql-load-script=import.sql

Run the test: FAILED

java.lang.RuntimeException: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
    [error]: Build step io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor#configurationDescriptorBuilding threw an exception: 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.

Edit the application.properties with this content:

quarkus.datasource.query-service.db-kind=postgresql

quarkus.hibernate-orm.query-service.datasource=query-service
quarkus.hibernate-orm.query-service.packages=org.acme.hibernate.orm.panache.entity,org.acme.hibernate.orm.panache.repository
quarkus.hibernate-orm.query-service.database.generation=drop-and-create
quarkus.hibernate-orm.query-service.log.sql=true
quarkus.hibernate-orm.query-service.sql-load-script=import.sql

Run the test: PASS

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus version or git rev

3.6.6

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

@yrodiere yrodiere added the kind/bug Something isn't working label Jan 22, 2024
@yrodiere
Copy link
Member Author

Not this is with Quarkus 3.6.6; I didn't try this myself, so it might be solved with the large refactorings that happened in... 3.7 I think? We'd need to check.

@radcortez
Copy link
Member

The Hibernate Config is still using the old config structure, which seems to have a bug in the case where a Map key shadows a group property.

Moving to mappings should be able to fix the issue. In the meantime, my recommendation is to not use a map key that may shadow other configuration properties from the config root.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/config kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants