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

Conflit between hibernate.core versions for project with feature "hibernate-jpa" #2529

Open
baracil opened this issue Jul 6, 2024 · 2 comments
Assignees

Comments

@baracil
Copy link

baracil commented Jul 6, 2024

Projects created with the feature "hibernate-jpa" (either with version 4.5.0 or 4.5.1-SNAPSHOT) include the following dependencies :

    <dependency>
      <groupId>io.micronaut.data</groupId>
      <artifactId>micronaut-data-tx-hibernate</artifactId>  <--  version 4.8.1
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>io.micronaut.sql</groupId>
      <artifactId>micronaut-hibernate-jpa</artifactId>   <--- version 5.7.0 
      <scope>compile</scope>
    </dependency>

Both have a transitive dependency to org.hibernate.orm:hibernate-core but with two different versions :

  • 6.4.4.Final for micronaut-data-tx-hibernate (through io.micronaut.data:micronaut-data-connection-hibernate:4.8.1)
  • 6.5.2.Final for micronaut-hibernate-jpa

This can be seen with the maven command mvn dependency:tree -Dversion :

[INFO] |  \- io.micronaut.data:micronaut-data-connection-hibernate:jar:4.8.1:compile (version managed from 4.8.1)
[INFO] |     +- (io.micronaut:micronaut-inject:jar:4.5.3:compile - version managed from 4.5.0; omitted for duplicate)
[INFO] |     +- (org.hibernate.orm:hibernate-core:jar:6.5.2.Final:compile - version managed from 6.4.4.Final; omitted for duplicate)
[INFO] |     \- (io.micronaut.data:micronaut-data-connection:jar:4.8.1:compile - version managed from 4.8.1; omitted for duplicate)
@graemerocher
Copy link
Contributor

not sure this conflict should matter. The version is managed in the this BOM https://github.com/micronaut-projects/micronaut-sql/blob/5.7.x/gradle/libs.versions.toml see https://central.sonatype.com/artifact/io.micronaut.sql/micronaut-sql-bom

how is this causing an issue for you?

@baracil
Copy link
Author

baracil commented Jul 8, 2024

The project I work on uses those 2 dependencies. For some reason, when I use the maven-dependency-plugin to create a directory containing all the dependencies, this is the version 6.4.4.Final that is copied (so maybe this is more a issue in the maven plugin...)

When I launch the application (using the directory created by the maven plugin as classpath), I get the following error :

#Message: No bean of type [jakarta.persistence.EntityManager] exists.

If I remove the version 6.4.4.Final (the jar file) and put the 6.5.2.Final in the directory created by the maven plugin, the application launches without issue.

Below are a snippet when the logs diverge between 6.4.4.Final and 6.5.2.Final :

6.4.4.Final
2024-07-08 06:29:31,096 [main] TRACE () i.m.context.DefaultBeanContext - Looking up existing bean for key: em
2024-07-08 06:29:31,096 [main] DEBUG () i.m.context.DefaultBeanContext - Finding candidate beans for type: EntityManager em
2024-07-08 06:29:31,096 [main] DEBUG () i.m.context.DefaultBeanContext - No bean candidates found for type: EntityManager em
2024-07-08 06:29:31,096 [main] DEBUG () i.m.context.DefaultBeanContext - Finding candidate beans for type: EntityManager em
2024-07-08 06:29:31,097 [main] DEBUG () i.m.context.DefaultBeanContext - No bean candidates found for type: EntityManager em
2024-07-08 06:29:31,098 [main] DEBUG () i.m.context.DefaultBeanContext - No bean candidates found for type: EntityManager em
... then it fails...
6.5.2.Final
2024-07-08 07:01:46,106 [main] TRACE () i.m.context.DefaultBeanContext - Looking up existing bean for key: em
2024-07-08 07:01:46,106 [main] DEBUG () i.m.context.DefaultBeanContext - Finding candidate beans for type: EntityManager em
2024-07-08 07:01:46,106 [main] DEBUG () i.m.context.DefaultBeanContext - Finding candidate beans for type: SessionFactory
2024-07-08 07:01:46,107 [main] DEBUG () i.m.context.DefaultBeanContext - Finding candidate beans for type: SessionFactoryPerDataSourceFactory
... then is succeed ...

(Du to the nature of the project, I cannot share more information with the log, sorry)

I had to add <exclusions/> on the version 6.4.4.Final to be able to package with the correct version.
Finally, for completeness, the issue arise when I simply upgrade from Micronaut 4.3 to 4.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants