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

Native Image Application w/ Hibernate Breaks w/ Latest Reachability Metadata #35103

Closed
matthenry87 opened this issue Apr 21, 2023 · 7 comments
Closed
Labels
for: external-project For an external project and not something we can fix

Comments

@matthenry87
Copy link

matthenry87 commented Apr 21, 2023

Spring Boot is using Hibernate Core 6.1.7.Final. Hints are only available for 6.1.1 and now 6.2.x. The Native plugin chooses the latest version by default if it can't find the version it's using, which now breaks the image, and it fails to start.

The managed configuration for the plugin should be updated to point to 6.1.1 hints so that Spring apps work without additional configuration.

I'll try to get a reproducer app together shortly, but this one is pretty straight forward.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 21, 2023
@wilkinsona
Copy link
Member

With Gradle, we could configure this like so:

graalvmNative {
    metadataRepository {
        moduleToConfigVersion.put("org.hibernate.orm:hibernate-core:6.1.1)
    }
}

I'm not sure how easy it would be to provide similar configuration for Maven. We may be able to do something in spring-boot-starter-parent. Either way, I'm not sure that we should.

The mapping is really a workaround either for broken metadata or for the behavior of the native build tools plugins. It would be better to address the problem in one of those locations. If we add a workaround it's hard to know when to remove it and keeping it around for too long may do more harm than good. We'd need to consider the version of the NBT plugin that's in use. We'd also have to consider the version of the "official" reachability metadata that's being used and account for the fact that custom metadata is also supported.

I'll flag this one for team discussion. In the meantime, @matthenry87, can you please open an NBT issue as I think the reachability metadata repository support should match versions more intelligently.

@wilkinsona wilkinsona added the for: team-meeting An issue we'd like to discuss as a team to make progress label Apr 24, 2023
@matthenry87
Copy link
Author

Created graalvm/native-build-tools#430.

@ch4mpy
Copy link

ch4mpy commented Apr 26, 2023

Duplicating here the 2 workarounds for Maven (already posted in the closed issue linked just above):

  • downgrade native-maven-plugin from 0.9.21 to 0.9.20
<plugin>
	<groupId>org.graalvm.buildtools</groupId>
	<artifactId>native-maven-plugin</artifactId>
	<version>0.9.20</version>
</plugin>
  • use an earlier native metadata repository for hibernate-core (same thing as done above by @wilkinsona for Gradle):
<plugin>
	<groupId>org.graalvm.buildtools</groupId>
	<artifactId>native-maven-plugin</artifactId>
	<configuration>
		<metadataRepository>
			<dependencies>
				<dependency>
					<groupId>org.hibernate.orm</groupId>
					<artifactId>hibernate-core</artifactId>
					<metadataVersion>6.1.1.Final</metadataVersion>
				</dependency>
			</dependencies>
		</metadataRepository>
	</configuration>
</plugin>

@wilkinsona
Copy link
Member

For anyone interested in the workarounds, downgrading the native build plugin helps because it also downgrades the version of the reachability metadata that's used by default. A more focussed workaround would be to just configure the metadata version instead. 0.2.7 contains the metadata for Hibernate 6.2 which breaks Hibernate 6.1.x. Downgrading to 0.2.6 should solve the problem:

<metadataRepository>
    <enabled>true</enabled>
    <version>0.2.6</version>
</metadataRepository>
graalvmNative {
    metadataRepository {
        version = "0.2.6"
    }
}

@sdeleuze
Copy link
Contributor

FYI I start working on oracle/graalvm-reachability-metadata#62 with related NBT changes in order to fix this issue and prevent similar one to appear, with the goal to get it included in Spring Boot 3.0.7 if that's ok for the Spring team.

@wilkinsona
Copy link
Member

wilkinsona commented Apr 28, 2023

Given the various workarounds that are available and the work being done to address this in NBT and the reachability metadata, I'm going to close this one now as I don't think baking a workaround into Spring Boot will serve us particularly well at this point.

@wilkinsona wilkinsona closed this as not planned Won't fix, can't repro, duplicate, stale Apr 28, 2023
@wilkinsona wilkinsona added for: external-project For an external project and not something we can fix and removed status: waiting-for-triage An issue we've not yet triaged for: team-meeting An issue we'd like to discuss as a team to make progress labels Apr 28, 2023
@ArnauAregall
Copy link

For context if you land here looking for help, workarounds are still needed even with latest versions.

  • SB 3.1.0-RC2
  • NBT 0.9.22
  • metadata 0.3.0

See oracle/graalvm-reachability-metadata#273 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix
Projects
None yet
Development

No branches or pull requests

6 participants