quarkus: Named persistence unit is broken in hibernate-orm-panache-kotlin 2.0.0.Final+
Describe the bug
I have 2 persistence units “admin” and “customer” associate with “c.s.c.e.admin” and “c.s.c.e.customer” packages.
Expected behavior
c.s.c.e.admin.Entity should work properly as before (1.13.6.Final).
Actual behavior
c.s.c.e.admin.Entity failed due to not able to resolve the associated persistence unit.
Masked stacktrace
2021-06-30T15:09:15.348+07:00 INFO [io.quarkus] Profile dev activated. Live Coding activated.
2021-06-30T15:09:15.350+07:00 INFO [io.quarkus] Installed features: [agroal, cache, cdi, config-yaml, hibernate-orm, hibernate-orm-panache-kotlin, jdbc-mysql, kotlin, narayana-jta, resteasy, resteasy-jackson, security, smallrye-context-propagation, smallrye-health, smallrye-jwt, smallrye-metrics, smallrye-openapi, swagger-ui, vertx, vertx-web]
2021-06-30T15:10:22.623+07:00 WARN [com.arj.ats.arjuna] ARJUNA012117: TransactionReaper::check processing TX 0:ffffc0a87124:16b3:60dc26ad:0 in state RUN
2021-06-30T15:10:22.625+07:00 WARN [com.arj.ats.arjuna] ARJUNA012095: Abort of action id 0:ffffc0a87124:16b3:60dc26ad:0 invoked while multiple threads active within it.
2021-06-30T15:10:22.628+07:00 WARN [com.arj.ats.arjuna] ARJUNA012381: Action id 0:ffffc0a87124:16b3:60dc26ad:0 completed with multiple threads - thread executor-thread-0 was in progress with com.arjuna.ats.arjuna.coordinator.BasicAction.Abort(BasicAction.java:1636)
/*retracted stack trace*/
2021-06-30T15:10:22.629+07:00 WARN [com.arj.ats.arjuna] ARJUNA012108: CheckedAction::check - atomic action 0:ffffc0a87124:16b3:60dc26ad:0 aborting with 1 threads active!
2021-06-30T15:10:22.629+07:00 WARN [com.arj.ats.arjuna] ARJUNA012121: TransactionReaper::doCancellations worker Thread[Transaction Reaper Worker 0,5,main] successfully canceled TX 0:ffffc0a87124:16b3:60dc26ad:0
2021-06-30T15:10:22.629+07:00 WARN [com.arj.ats.arjuna] ARJUNA012077: Abort called on already aborted atomic action 0:ffffc0a87124:16b3:60dc26ad:0
2021-06-30T15:10:22.639+07:00 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] HTTP Request to /api/services failed, error id: 62ec378c-2c22-441e-8c2d-8f5d684ade91-1: java.lang.IllegalStateException: The default datasource has not been properly configured. See https://quarkus.io/guides/datasource#jdbc-datasource for information on how to do that.
at io.quarkus.hibernate.orm.panache.common.runtime.AbstractJpaOperations.getEntityManager(AbstractJpaOperations.java:62)
at io.quarkus.hibernate.orm.panache.common.runtime.AbstractJpaOperations.getEntityManager(AbstractJpaOperations.java:51)
at io.quarkus.hibernate.orm.panache.common.runtime.AbstractJpaOperations.findById(AbstractJpaOperations.java:177)
at c.s.c.e.admin.Entity$Companion.findById(Entity.kt)
/*retracted stack trace*/
2021-06-30T15:10:22.653+07:00 INFO [access-log] 127.0.0.1 - - "GET /api/services HTTP/1.1" 500 17129 -
2021-06-30T15:10:22.656+07:00 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] HTTP Request to /api/services failed, error id: 62ec378c-2c22-441e-8c2d-8f5d684ade91-2: java.lang.IllegalStateException: The default datasource has not been properly configured. See https://quarkus.io/guides/datasource#jdbc-datasource for information on how to do that.
at io.quarkus.hibernate.orm.panache.common.runtime.AbstractJpaOperations.getEntityManager(AbstractJpaOperations.java:62)
at io.quarkus.hibernate.orm.panache.common.runtime.AbstractJpaOperations.getEntityManager(AbstractJpaOperations.java:51)
at io.quarkus.hibernate.orm.panache.common.runtime.AbstractJpaOperations.findById(AbstractJpaOperations.java:177)
at c.s.c.e.admin.Entity$Companion.findById(Entity.kt)
/*retracted stack trace*/
Configuration
quarkus:
datasource:
admin:
customer:
hibernate-orm:
admin:
packages: c.s.c.e.admin
customer:
packages: c.s.c.e.cust
Screenshots
Direct cause would be AbstractJpaOperations.entityToPersistenceUnit lost it value (reverted after being set) to default empty
entityToPersistenceUnit map is being set (12 entries)

entityToPersistenceUnit is empty while being used

Reproduce steps
https://github.com/bboyz269/hibernate-orm-panache-kotlin-multi-persistence-unit
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 22 (15 by maintainers)
@evanchooly could you have a look to see if it’s a Kotlin-specific issue? We have tests for multiple persistence units support for Java I think so maybe it’s a corner case but it might as well be Kotlin-related.
Thanks.