alvessteve / fizzbuzz-rest-api

Simple REST-API example
1 stars 1 forks source link

Native Image: fix startup error #26

Open alvessteve opened 1 year ago

alvessteve commented 1 year ago

Error:

java.lang.illegalstateexception: no available jtaplatform candidates amongst [org.hibernate.engine.transaction.jta.platform.internal.nojtaplatform, org.hibernate.service.jta.platform.internal.nojtaplatform]

alvessteve commented 1 year ago

seems related to this: https://github.com/spring-projects/spring-boot/issues/32659

matthenry87 commented 1 year ago

Running into this after upgrading to Spring Boot 3.0.6 today, on a previously working native image app.

Will try to get a reproducer project together soon.

Edit: Just realized this isn't a Spring repo LOL.

matthenry87 commented 1 year ago

There was a set of new hints added to the GraalVM reachibility metadata repository for Hibernate Core. This new set of hints appears to be missing hints that the previous version's set had.

So far I've had to add these hints (currently adding via code):

            hints.reflection()
                    .registerType(NoJtaPlatform.class, INTROSPECT_PUBLIC_METHODS)
                    .registerConstructor(NoJtaPlatform.class.getConstructor(), INVOKE)

                    .registerConstructor(SpringImplicitNamingStrategy.class.getConstructor(), INVOKE)
                    .registerConstructor(CamelCaseToUnderscoresNamingStrategy.class.getConstructor(), INVOKE);
matthenry87 commented 1 year ago
<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>

This fixed it for me. (I'm using Maven, not Gradle)

alvessteve commented 1 year ago

Thank you very much for the hints ! will try these

ArnauAregall commented 1 year ago

I also started experiencing the same issue in one of my repositories after upgrading GraalVM Build tools native plugin (org.graalvm.buildtools.native) from 0.9.20 to 0.9.21.

https://github.com/ArnauAregall/kotlin-spring-data-rest-movies/commit/e198340d2925cab8f1ebdf79a7d491e84f3f35f5

Downgrading again to 0.9.20 worked fine again (using Gradle).