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

Improve error message when multiple hibernate interceptors are found #41992

Closed
Postremus opened this issue Jul 19, 2024 · 6 comments · Fixed by #42190
Closed

Improve error message when multiple hibernate interceptors are found #41992

Postremus opened this issue Jul 19, 2024 · 6 comments · Fixed by #42190
Labels
area/hibernate-orm Hibernate ORM good first issue Good for newcomers kind/enhancement New feature or request
Milestone

Comments

@Postremus
Copy link
Member

Description

Can this message please be expanded to include the fqdn of the interceptors

__  ____  __  _____   ___  __ ____  ______                                                                                                                                                                                                                                           
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2024-07-19 08:41:20,146 WARN  [org.hib.dia.Dialect] (Quarkus Main Thread) HHH000511: The 11.5.0 version for [org.hibernate.dialect.PostgreSQLDialect] is no longer supported, hence certain features may not work properly. The minimum supported version is 12.0.0. Check the community dialects project for available legacy versions.

2024-07-19 08:41:21,902 ERROR [io.qua.run.Application] (Quarkus Main Thread) Failed to start application (with profile [dev]): 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:111)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:124)
        at io.quarkus.runner.GeneratedMain.main(Unknown Source)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:113)
        at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: jakarta.persistence.PersistenceException: [PersistenceUnit: <default>] Unable to build Hibernate SessionFactory
        at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBuilder.persistenceException(FastBootEntityManagerFactoryBuilder.java:129)
        at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBuilder.build(FastBootEntityManagerFactoryBuilder.java:89)
        at io.quarkus.hibernate.orm.runtime.FastBootHibernatePersistenceProvider.createEntityManagerFactory(FastBootHibernatePersistenceProvider.java:72)
        at jakarta.persistence.Persistence.createEntityManagerFactory(Persistence.java:80)
        at jakarta.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
        at io.quarkus.hibernate.orm.runtime.JPAConfig$LazyPersistenceUnit.get(JPAConfig.java:154)
        at io.quarkus.hibernate.orm.runtime.JPAConfig$1.run(JPAConfig.java:61)
        ... 1 more
Caused by: java.lang.IllegalStateException: Multiple instances of Interceptor were found for persistence unit <default>. At most one instance can be assigned to each persistence unit.
        at io.quarkus.hibernate.orm.runtime.PersistenceUnitUtil.singleExtensionInstanceForPersistenceUnit(PersistenceUnitUtil.java:33)
        at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBuilder.populate(FastBootEntityManagerFactoryBuilder.java:206)
        at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBuilder.build(FastBootEntityManagerFactoryBuilder.java:85)
        ... 6 more

Implementation ideas

No response

@Postremus Postremus added the kind/enhancement New feature or request label Jul 19, 2024
@quarkus-bot quarkus-bot bot added area/hibernate-orm Hibernate ORM area/persistence OBSOLETE, DO NOT USE labels Jul 19, 2024
Copy link

quarkus-bot bot commented Jul 19, 2024

/cc @gsmet (hibernate-orm), @yrodiere (hibernate-orm)

@Postremus Postremus removed the area/persistence OBSOLETE, DO NOT USE label Jul 19, 2024
@geoand
Copy link
Contributor

geoand commented Jul 19, 2024

Agreed, at the very least the method should mention which instances are "competing".

Also from what I can tell, the error could be thrown at build time instead of runtime as the presence of multiple beans is known at build time.

@yrodiere
Copy link
Member

yrodiere commented Jul 19, 2024

Agreed, at the very least the method should mention which instances are "competing".

True. The method to improve is PersistenceUnitUtil.singleExtensionInstanceForPersistenceUnit, you can list beans using instance.handles() and InstanceHandle#getBean().
Similar problems exist in io.quarkus.hibernate.search.orm.elasticsearch.runtime.bean.HibernateSearchBeanUtil#singleExtensionBeanReferenceFor(java.lang.Class<T>, java.lang.String, java.lang.String, java.lang.String) and io.quarkus.hibernate.search.standalone.elasticsearch.runtime.bean.HibernateSearchBeanUtil#singleExtensionBeanReferenceFor(java.lang.Class<T>, java.lang.String, java.lang.String).

PRs welcome!

Also from what I can tell, the error could be thrown at build time instead of runtime as the presence of multiple beans is known at build time.

Also true, but would require more work, and would possibly be much more clunky due to the nice CDI APIs not being available.
Wouldn't recommend this change to whoever will fix this, unless they're very familiar with Quarkus internals (Arc in particular).

@yrodiere yrodiere added the good first issue Good for newcomers label Jul 19, 2024
@geoand
Copy link
Contributor

geoand commented Jul 19, 2024

Wouldn't recommend this change to whoever will fix this

Agreed, just something to keep in mind for the future

@Chu3laMan
Copy link

I am interested to work in this issue as long as would some guidance
Thanks in advance

@yrodiere
Copy link
Member

All the guidance you should need is in the messages above; if that's not enough, ask away, but I won't be providing a step-by-step guide as it would take me as much time as doing it myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/hibernate-orm Hibernate ORM good first issue Good for newcomers kind/enhancement New feature or request
Projects
None yet
4 participants