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.

Comment From: wilkinsona

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.

Comment From: matthenry87

Created https://github.com/graalvm/native-build-tools/issues/430.

Comment From: ch4mpy

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>

Comment From: wilkinsona

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"
    }
}

Comment From: sdeleuze

FYI I start working on https://github.com/oracle/graalvm-reachability-metadata/issues/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.

Comment From: wilkinsona

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.

Comment From: ArnauAregall

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 https://github.com/oracle/graalvm-reachability-metadata/issues/273#issuecomment-1546829924