From 6a4b2be512c45eba3d545a65150068799d1abc46 Mon Sep 17 00:00:00 2001 From: Matt Raible Date: Tue, 27 Oct 2026 16:19:52 -0600 Subject: [PATCH] Fix imperative Helidon native image build and startup The publish workflow has failed at the Helidon native build since August. GraalVM 25 only allows --static with musl libc, and GraalVM 21's static glibc build fails to link. This applies the workaround a Helidon maintainer recommends in helidon-io/helidon#10767: build a regular dynamically linked binary and run it on oraclelinux:9-slim instead of scratch. The native app also crashed on startup with NoSuchMethodException for RoleAnnotationAnalyzer.init. Since 4.4, Helidon checks by reflection whether an annotation analyzer overrides a deprecated init method, and the native image had no reflection metadata for that lookup. reflect-config.json now registers public methods for both annotation analyzers on the classpath. --- imperative/helidon/Dockerfile.native | 4 ++-- .../com/example/rest/helidon/reflect-config.json | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 imperative/helidon/src/main/resources/META-INF/native-image/com/example/rest/helidon/reflect-config.json diff --git a/imperative/helidon/Dockerfile.native b/imperative/helidon/Dockerfile.native index 18529aa..376e1d9 100644 --- a/imperative/helidon/Dockerfile.native +++ b/imperative/helidon/Dockerfile.native @@ -23,12 +23,12 @@ RUN mvn package -Pnative-image -Dnative.image.skip -Dmaven.test.skip -Declipseli # Do the Maven build! # Incremental docker builds will resume here when you change sources ADD src src -RUN mvn package -Pnative-image -Dnative.image.buildStatic -DskipTests +RUN mvn package -Pnative-image -DskipTests RUN echo "done!" # 2nd stage, build the runtime image -FROM scratch +FROM container-registry.oracle.com/os/oraclelinux:9-slim WORKDIR /helidon # Copy the binary built in the 1st stage diff --git a/imperative/helidon/src/main/resources/META-INF/native-image/com/example/rest/helidon/reflect-config.json b/imperative/helidon/src/main/resources/META-INF/native-image/com/example/rest/helidon/reflect-config.json new file mode 100644 index 0000000..5dcc079 --- /dev/null +++ b/imperative/helidon/src/main/resources/META-INF/native-image/com/example/rest/helidon/reflect-config.json @@ -0,0 +1,10 @@ +[ + { + "name": "io.helidon.microprofile.jwt.auth.JwtAuthAnnotationAnalyzer", + "queryAllPublicMethods": true + }, + { + "name": "io.helidon.security.abac.role.RoleAnnotationAnalyzer", + "queryAllPublicMethods": true + } +]