Closed morki closed 10 months ago
@ilopmar can you please take a look?
I tried debugging it and adding --initialize-at-run-time
for those classes did not work.
I looked at the "problematic" class and did't find anything that can make native-image think that it cannot be initialized at build time - no threads, no references.
@morki adding --initialize-at-run-time=com.fasterxml.jackson.dataformat.xml.util.StaxUtil$Base64Mapper
makes it possible to create the native image, but I don't know if that's enough or not. If not, please provide a sample application.
Thank you @ilopmar for your time. Unfortunately that did not work as I said in previous comment. The exception is still the same which is weird.
Sample application is as simple as running:
mn create-app --build=gradle --jdk=11 --lang=java --test=junit --features=netty-server,jackson-xml com.example.demo
and then .gradlew dockerBuildNative
.
You don't even need to use it in any way. Just inclusion of this module creates the error.
This is really strange. I've created the app and added the following to build.gradle
graalvmNative {
toolchainDetection = false
binaries {
main {
buildArgs.add('--initialize-at-run-time=com.fasterxml.jackson.dataformat.xml.util.StaxUtil$Base64Mapper')
}
}
}
Then, building the native image inside docker, you can see that the initialize-at-run-time param is passed to the native-image command, but even with that, it fails.
ivan@doraemon:~/workspaces/micronaut-apps/issue-jackson-xml-157$ gw dockerBuildNative
> Task :compileJava UP-TO-DATE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :runnerJar UP-TO-DATE
> Task :buildNativeLayersTask UP-TO-DATE
> Task :jar UP-TO-DATE
> Task :generateResourcesConfigFile UP-TO-DATE
> Task :dockerfileNative
Dockerfile written to: /home/ivan/workspaces/micronaut-apps/issue-jackson-xml-157/build/docker/native-main/DockerfileNative
> Task :dockerPrepareContext UP-TO-DATE
> Task :dockerBuildNative
Building image using context '/home/ivan/workspaces/micronaut-apps/issue-jackson-xml-157/build/docker/native-main'.
Using Dockerfile '/home/ivan/workspaces/micronaut-apps/issue-jackson-xml-157/build/docker/native-main/DockerfileNative'
Using images 'demo'.
Step 1/13 : FROM ghcr.io/graalvm/native-image:java11-21.3.0 AS graalvm
---> 6900560f8360
Step 2/13 : WORKDIR /home/app
---> Using cache
---> df97d1d8cb6d
Step 3/13 : COPY layers/libs /home/app/libs
---> Using cache
---> 1be2f7625986
Step 4/13 : COPY layers/classes /home/app/classes
---> Using cache
---> 7d0737b265dc
Step 5/13 : COPY layers/resources /home/app/resources
---> Using cache
---> de792ede2ffd
Step 6/13 : COPY layers/application.jar /home/app/application.jar
---> Using cache
---> 4cd2aba2be83
Step 7/13 : RUN mkdir /home/app/config-dirs
---> Using cache
---> 4a2422381f91
Step 8/13 : COPY config-dirs/generateResourcesConfigFile /home/app/config-dirs/generateResourcesConfigFile
---> Using cache
---> 261a62ea68d5
Step 9/13 : RUN native-image -cp /home/app/libs/*.jar:/home/app/resources:/home/app/application.jar --no-fallback -H:Name=application -H:ConfigurationFileDirectories=/home/app/config-dirs/generateResourcesConfigFile -H:Class=com.example.Application --initialize-at-run-time=com.fasterxml.jackson.dataformat.xml.util.StaxUtil$Base64Mapper
---> Running in e3ba7ccfdc1e
[application:28] classlist: 4,947.07 ms, 0.93 GB
[application:28] (cap): 822.34 ms, 0.93 GB
[application:28] setup: 3,552.90 ms, 0.93 GB
To see how the classes got initialized, use --trace-class-initialization=org.codehaus.stax2.typed.Base64Variants
[application:28] analysis: 46,778.54 ms, 5.01 GB
Error: Classes that should be initialized at run time got initialized during image building:
org.codehaus.stax2.typed.Base64Variants was unintentionally initialized at build time. To see why org.codehaus.stax2.typed.Base64Variants got initialized use --trace-class-initialization=org.codehaus.stax2.typed.Base64Variants
Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
[application:28] [total]: 55,803.14 ms, 5.01 GB
# Printing build artifacts to: /home/app/application.build_artifacts.txt
Error: Image build request failed with exit status 1
> Task :dockerBuildNative FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':dockerBuildNative'.
> Could not build image: The command '/bin/sh -c native-image -cp /home/app/libs/*.jar:/home/app/resources:/home/app/application.jar --no-fallback -H:Name=application -H:ConfigurationFileDirectories=/home/app/config-dirs/generateResourcesConfigFile -H:Class=com.example.Application --initialize-at-run-time=com.fasterxml.jackson.dataformat.xml.util.StaxUtil$Base64Mapper' returned a non-zero code: 1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 4s
9 actionable tasks: 2 executed, 7 up-to-date
Now, without modifying anything I build the native image locally and it works:
ivan@doraemon:~/workspaces/micronaut-apps/issue-jackson-xml-157$ sdk use java 21.3.0.r11-grl
Using java version 21.3.0.r11-grl in this shell.
ivan@doraemon:~/workspaces/micronaut-apps/issue-jackson-xml-157$ gw nativeCompile
Starting a Gradle Daemon, 2 incompatible Daemons could not be reused, use --status for details
> Task :compileJava UP-TO-DATE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :jar UP-TO-DATE
> Task :generateResourcesConfigFile UP-TO-DATE
> Task :nativeCompile
Toolchain detection is disabled, will use GraalVM from /home/ivan/.sdkman/candidates/java/21.3.0.r11-grl.
[native-image-plugin] Using executable path: /home/ivan/.sdkman/candidates/java/21.3.0.r11-grl/bin/native-image
[demo:20225] classlist: 3,468.34 ms, 1.18 GB
[demo:20225] (cap): 673.30 ms, 1.18 GB
[demo:20225] setup: 2,946.54 ms, 1.18 GB
[demo:20225] (clinit): 1,657.04 ms, 6.14 GB
[demo:20225] (typeflow): 8,734.23 ms, 6.14 GB
[demo:20225] (objects): 43,519.14 ms, 6.14 GB
[demo:20225] (features): 25,049.09 ms, 6.14 GB
[demo:20225] analysis: 83,589.93 ms, 6.14 GB
[demo:20225] universe: 5,591.79 ms, 6.14 GB
[demo:20225] (parse): 4,730.49 ms, 6.19 GB
[demo:20225] (inline): 9,213.95 ms, 6.35 GB
[demo:20225] (compile): 42,928.67 ms, 6.42 GB
[demo:20225] compile: 61,352.41 ms, 6.42 GB
[demo:20225] image: 5,496.74 ms, 6.42 GB
[demo:20225] write: 890.01 ms, 6.42 GB
[demo:20225] [total]: 163,816.97 ms, 6.42 GB
# Printing build artifacts to: /home/ivan/workspaces/micronaut-apps/issue-jackson-xml-157/build/native/nativeCompile/demo.build_artifacts.txt
[native-image-plugin] Native Image written to: /home/ivan/workspaces/micronaut-apps/issue-jackson-xml-157/build/native/nativeCompile
BUILD SUCCESSFUL in 2m 53s
5 actionable tasks: 1 executed, 4 up-to-date
Wow, maybe some docker related bug? Do you have any idea? We use docker build in our pipeline.
I've added --verbose
and I see that when building the image inside Docker, JDK17 is used somehow even if we are pulling the JDK11 version:
ivan@doraemon:~/workspaces/micronaut-apps/issue-jackson-xml-157$ gw dockerBuildNative
...
> Task :dockerBuildNative
Building image using context '/home/ivan/workspaces/micronaut-apps/issue-jackson-xml-157/build/docker/native-main'.
Using Dockerfile '/home/ivan/workspaces/micronaut-apps/issue-jackson-xml-157/build/docker/native-main/DockerfileNative'
Using images 'demo'.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! HERE WE USE ghcr.io/graalvm/native-image:java11-21.3.0
Step 1/13 : FROM ghcr.io/graalvm/native-image:java11-21.3.0 AS graalvm
...
...
Step 9/13 : RUN native-image -cp /home/app/libs/*.jar:/home/app/resources:/home/app/application.jar --no-fallback -H:Name=application -H:ConfigurationFileDirectories=/home/app/config-dirs/generateResourcesConfigFile -H:Class=com.example.Application --verbose --initialize-at-run-time=com.fasterxml.jackson.dataformat.xml.util.StaxUtil$Base64Mapper
---> Running in 69ce6c3903ca
Executing [
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! JDK17
/usr/lib64/graalvm/graalvm21-ce-java17/bin/java \
-XX:+UseParallelGC \
-XX:+UnlockExperimentalVMOptions \
-XX:+EnableJVMCI \
-Dtruffle.TrustAllTruffleRuntimeProviders=true \
-Dtruffle.TruffleRuntime=com.oracle.truffle.api.impl.DefaultTruffleRuntime \
-Dgraalvm.ForcePolyglotInvalid=true \
-Dgraalvm.locatorDisabled=true \
-Dsubstratevm.IgnoreGraalVersionCheck=true \
--add-exports=java.base/com.sun.crypto.provider=ALL-UNNAMED \
--add-exports=java.base/jdk.internal.access.foreign=ALL-UNNAMED \
--add-exports=java.base/jdk.internal.event=ALL-UNNAMED \
--add-exports=java.base/jdk.internal.loader=ALL-UNNAMED \
--add-exports=java.base/jdk.internal.logger=ALL-UNNAMED \
--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED \
--add-exports=java.base/jdk.internal.module=ALL-UNNAMED \
--add-exports=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED \
--add-exports=java.base/jdk.internal.org.xml.sax.helpers=ALL-UNNAMED \
--add-exports=java.base/jdk.internal.perf=ALL-UNNAMED \
--add-exports=java.base/jdk.internal.platform=ALL-UNNAMED \
--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED \
--add-exports=java.base/jdk.internal.reflect=ALL-UNNAMED \
--add-exports=java.base/jdk.internal.util.xml.impl=ALL-UNNAMED \
--add-exports=java.base/jdk.internal.util.xml=ALL-UNNAMED \
--add-exports=java.base/sun.invoke.util=ALL-UNNAMED \
--add-exports=java.base/sun.nio.ch=ALL-UNNAMED \
--add-exports=java.base/sun.reflect.annotation=ALL-UNNAMED \
--add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED \
--add-exports=java.base/sun.reflect.generics.repository=ALL-UNNAMED \
--add-exports=java.base/sun.reflect.generics.tree=ALL-UNNAMED \
--add-exports=java.base/sun.security.jca=ALL-UNNAMED \
--add-exports=java.base/sun.security.provider=ALL-UNNAMED \
--add-exports=java.base/sun.security.util=ALL-UNNAMED \
--add-exports=java.base/sun.text.spi=ALL-UNNAMED \
--add-exports=java.base/sun.util.calendar=ALL-UNNAMED \
--add-exports=java.base/sun.util.locale.provider=ALL-UNNAMED \
--add-exports=java.base/sun.util.resources=ALL-UNNAMED \
--add-exports=java.xml.crypto/org.jcp.xml.dsig.internal.dom=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.aarch64=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.amd64=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code.site=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code.stack=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.common=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.aarch64=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.amd64=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.meta=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.runtime=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.services=ALL-UNNAMED \
--add-exports=jdk.jfr/jdk.jfr.events=ALL-UNNAMED \
--add-exports=jdk.jfr/jdk.jfr.internal.consumer=ALL-UNNAMED \
--add-exports=jdk.jfr/jdk.jfr.internal.handlers=ALL-UNNAMED \
--add-exports=jdk.jfr/jdk.jfr.internal.jfc=ALL-UNNAMED \
--add-exports=jdk.jfr/jdk.jfr.internal=ALL-UNNAMED \
-XX:+UseJVMCINativeLibrary \
-Xss10m \
-Xms1g \
-Xmx14g \
-Duser.country=US \
-Duser.language=en \
-Djava.awt.headless=true \
-Dorg.graalvm.version=21.3.0 \
-Dorg.graalvm.config=CE \
-Dcom.oracle.graalvm.isaot=true \
-Djava.system.class.loader=com.oracle.svm.hosted.NativeImageSystemClassLoader \
-Xshare:off \
-Djdk.internal.lambda.disableEagerInitialization=true \
-Djdk.internal.lambda.eagerlyInitialize=false \
-Djava.lang.invoke.InnerClassLambdaMetafactory.initializeLambdas=false \
-javaagent:/usr/lib64/graalvm/graalvm21-ce-java17/lib/svm/builder/svm.jar \
-cp \
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! All libs are from JDK17
/usr/lib64/graalvm/graalvm21-ce-java17/lib/svm/builder/llvm-wrapper-shadowed.jar:/usr/lib64/graalvm/graalvm21-ce-java17/lib/svm/builder/svm.jar:/usr/lib64/graalvm/graalvm21-ce-java17/lib/svm/builder/llvm-platform-specific-shadowed.jar:/usr/lib64/graalvm/graalvm21-ce-java17/lib/svm/builder/javacpp-shadowed.jar:/usr/lib64/graalvm/graalvm21-ce-java17/lib/svm/builder/svm-llvm.jar:/usr/lib64/graalvm/graalvm21-ce-java17/lib/svm/builder/pointsto.jar:/usr/lib64/graalvm/graalvm21-ce-java17/lib/svm/builder/objectfile.jar \
--module-path \
/usr/lib64/graalvm/graalvm21-ce-java17/lib/truffle/truffle-api.jar \
'com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus' \
-watchpid \
1 \
-imagecp \
'/home/app/libs/micronaut-jackson-xml-3.0.0.jar:/home/app/libs/micronaut-http-client-3.2.4.jar:/home/app/libs/micronaut-http-server-netty-3.2.4.jar:/home/app/libs/micronaut-http-netty-3.2.4.jar:/home/app/libs/micronaut-http-server-3.2.4.jar:/home/app/libs/micronaut-websocket-3.2.4.jar:/home/app/libs/micronaut-http-client-core-3.2.4.jar:/home/app/libs/micronaut-runtime-3.2.4.jar:/home/app/libs/micronaut-validation-3.2.4.jar:/home/app/libs/micronaut-router-3.2.4.jar:/home/app/libs/micronaut-jackson-databind-3.2.4.jar:/home/app/libs/micronaut-jackson-core-3.2.4.jar:/home/app/libs/micronaut-json-core-3.2.4.jar:/home/app/libs/micronaut-http-3.2.4.jar:/home/app/libs/micronaut-context-3.2.4.jar:/home/app/libs/micronaut-aop-3.2.4.jar:/home/app/libs/micronaut-buffer-netty-3.2.4.jar:/home/app/libs/micronaut-inject-3.2.4.jar:/home/app/libs/jakarta.annotation-api-2.0.0.jar:/home/app/libs/logback-classic-1.2.3.jar:/home/app/libs/jackson-dataformat-xml-2.12.4.jar:/home/app/libs/jackson-module-jaxb-annotations-2.12.4.jar:/home/app/libs/jackson-datatype-jdk8-2.12.4.jar:/home/app/libs/jackson-datatype-jsr310-2.12.4.jar:/home/app/libs/jackson-databind-2.12.4.jar:/home/app/libs/jackson-core-2.12.4.jar:/home/app/libs/jackson-annotations-2.12.4.jar:/home/app/libs/javax.annotation-api-1.3.2.jar:/home/app/libs/netty-handler-proxy-4.1.72.Final.jar:/home/app/libs/netty-codec-http2-4.1.72.Final.jar:/home/app/libs/netty-codec-http-4.1.72.Final.jar:/home/app/libs/netty-codec-socks-4.1.72.Final.jar:/home/app/libs/netty-handler-4.1.72.Final.jar:/home/app/libs/netty-codec-4.1.72.Final.jar:/home/app/libs/netty-transport-4.1.72.Final.jar:/home/app/libs/netty-buffer-4.1.72.Final.jar:/home/app/libs/reactor-core-3.4.8.jar:/home/app/libs/micronaut-core-reactive-3.2.4.jar:/home/app/libs/reactive-streams-1.0.3.jar:/home/app/libs/micronaut-core-3.2.4.jar:/home/app/libs/slf4j-api-1.7.29.jar:/home/app/libs/snakeyaml-1.29.jar:/home/app/libs/validation-api-2.0.1.Final.jar:/home/app/libs/netty-resolver-4.1.72.Final.jar:/home/app/libs/netty-common-4.1.72.Final.jar:/home/app/libs/netty-tcnative-classes-2.0.46.Final.jar:/home/app/libs/logback-core-1.2.3.jar:/home/app/libs/jakarta.inject-api-2.0.1.jar:/home/app/libs/woodstox-core-6.2.4.jar:/home/app/libs/stax2-api-4.2.1.jar:/home/app/libs/jakarta.xml.bind-api-2.3.2.jar:/home/app/libs/jakarta.activation-api-1.2.1.jar:/home/app/classes:/home/app/libs/*.jar:/home/app/resources:/home/app/application.jar:/usr/lib64/graalvm/graalvm21-ce-java17/lib/svm/library-support.jar' \
-H:Path=/home/app \
'-H:ReflectionConfigurationResources@jar:file:///home/app/libs/micronaut-http-server-netty-3.2.4.jar!/META-INF/native-image/io.micronaut/micronaut-http-server-netty/reflect-config.json=META-INF/native-image/io.micronaut/micronaut-http-server-netty/reflect-config.json' \
'-H:ReflectionConfigurationResources@jar:file:///home/app/libs/micronaut-http-netty-3.2.4.jar!/META-INF/native-image/io.micronaut/micronaut-http-netty/reflect-config.json=META-INF/native-image/io.micronaut/micronaut-http-netty/reflect-config.json' \
'-H:ClassInitialization@jar:file:///home/app/libs/micronaut-http-server-3.2.4.jar!/META-INF/native-image/io.micronaut/micronaut-http-server/native-image.properties=io.micronaut.http.server.exceptions.JsonExceptionHandler:run_time,io.micronaut.http.server.exceptions.$JsonExceptionHandler$Definition:run_time,io.micronaut.http.server.exceptions.$JsonExceptionHandler$Definition$Exec:run_time,io.micronaut.http.server.$CoroutineHelper$Definition:run_time' \
'-H:+InstallExitHandlers@jar:file:///home/app/libs/micronaut-runtime-3.2.4.jar!/META-INF/native-image/io.micronaut/micronaut-runtime/native-image.properties' \
'-H:ClassInitialization@jar:file:///home/app/libs/micronaut-runtime-3.2.4.jar!/META-INF/native-image/io.micronaut/micronaut-runtime/native-image.properties=io.micronaut.reactive.reactor.ReactorInstrumentation:run_time,io.micronaut.discovery.cloud.digitalocean.$DigitalOceanMetadataResolver$Definition:run_time' \
'-H:ClassInitialization@jar:file:///home/app/libs/micronaut-runtime-3.2.4.jar!/META-INF/native-image/io.micronaut/micronaut-runtime/native-image.properties=ch.qos.logback:build_time,io.micronaut:build_time,io.reactivex:build_time,org.reactivestreams:build_time,org.slf4j:build_time,org.yaml.snakeyaml:build_time,javax.xml:build_time' \
'-H:ClassInitialization@jar:file:///home/app/libs/micronaut-runtime-3.2.4.jar!/META-INF/native-image/io.micronaut/micronaut-runtime/native-image.properties=com.sun.org.apache.xerces.internal.util:build_time,com.sun.org.apache.xerces.internal.impl:build_time,jdk.xml.internal:build_time,com.sun.xml.internal.stream.util:build_time,com.sun.org.apache.xerces.internal.xni:build_time,com.sun.org.apache.xerces.internal.utils:build_time' \
'-H:ReflectionConfigurationResources@jar:file:///home/app/libs/micronaut-runtime-3.2.4.jar!/META-INF/native-image/io.micronaut/micronaut-runtime/reflect-config.json=META-INF/native-image/io.micronaut/micronaut-runtime/reflect-config.json' \
'-H:ClassInitialization@jar:file:///home/app/libs/micronaut-validation-3.2.4.jar!/META-INF/native-image/io.micronaut.validation/micronaut-validation/native-image.properties=io.micronaut.validation.exceptions.ValidationExceptionHandler:run_time,io.micronaut.validation.exceptions.$ValidationExceptionHandler$Definition:run_time,io.micronaut.validation.exceptions.$ValidationExceptionHandler$Definition$Exec:run_time,io.micronaut.validation.exceptions.$ConstraintExceptionHandler$Definition:run_time,io.micronaut.validation.exceptions.ConstraintExceptionHandler:run_time' \
'-H:ReflectionConfigurationResources@jar:file:///home/app/libs/micronaut-jackson-databind-3.2.4.jar!/META-INF/native-image/io.micronaut/micronaut-jackson-databind/reflect-config.json=META-INF/native-image/io.micronaut/micronaut-jackson-databind/reflect-config.json' \
'-H:ClassInitialization@jar:file:///home/app/libs/micronaut-jackson-core-3.2.4.jar!/META-INF/native-image/io.micronaut/micronaut-jackson-core/native-image.properties=com.fasterxml.jackson:build_time' \
'-H:IncludeResources@jar:file:///home/app/libs/micronaut-http-3.2.4.jar!/META-INF/native-image/io.micronaut.http/micronaut-http/native-image.properties=META-INF/http/mime.types' \
'-H:ClassInitialization@jar:file:///home/app/libs/micronaut-http-3.2.4.jar!/META-INF/native-image/io.micronaut.http/micronaut-http/native-image.properties=io.micronaut.http.bind.binders.ContinuationArgumentBinder:run_time,io.micronaut.http.server.CoroutineHelper:run_time' \
'-H:ReflectionConfigurationResources@jar:file:///home/app/libs/micronaut-http-3.2.4.jar!/META-INF/native-image/io.micronaut/micronaut-http/reflect-config.json=META-INF/native-image/io.micronaut/micronaut-http/reflect-config.json' \
'-H:ReflectionConfigurationResources@jar:file:///home/app/libs/micronaut-context-3.2.4.jar!/META-INF/native-image/io.micronaut/micronaut-context/reflect-config.json=META-INF/native-image/io.micronaut/micronaut-context/reflect-config.json' \
'-H:ClassInitialization@jar:file:///home/app/libs/micronaut-aop-3.2.4.jar!/META-INF/native-image/io.micronaut/micronaut-aop/native-image.properties=io.micronaut.aop.internal.intercepted.PublisherInterceptedMethod:run_time' \
'-H:+AllowIncompleteClasspath@jar:file:///home/app/libs/micronaut-inject-3.2.4.jar!/META-INF/native-image/io.micronaut/micronaut-inject/native-image.properties' \
'-H:EnableURLProtocols@jar:file:///home/app/libs/micronaut-inject-3.2.4.jar!/META-INF/native-image/io.micronaut/micronaut-inject/native-image.properties=http,https' \
'-H:ClassInitialization@jar:file:///home/app/libs/micronaut-inject-3.2.4.jar!/META-INF/native-image/io.micronaut/micronaut-inject/native-image.properties=io.micronaut.inject.provider.JakartaProviderBeanDefinition:run_time' \
'-H:ClassInitialization@jar:file:///home/app/libs/micronaut-inject-3.2.4.jar!/META-INF/native-image/io.micronaut/micronaut-inject/native-image.properties=io.micronaut.context.env.CachedEnvironment:run_time' \
'-H:ClassInitialization@jar:file:///home/app/libs/netty-codec-http2-4.1.72.Final.jar!/META-INF/native-image/io.netty/codec-http2/native-image.properties=io.netty:build_time' \
'-H:ClassInitialization@jar:file:///home/app/libs/netty-codec-http2-4.1.72.Final.jar!/META-INF/native-image/io.netty/codec-http2/native-image.properties=io.netty.handler.codec.http2.Http2CodecUtil:run_time,io.netty.handler.codec.http2.Http2ClientUpgradeCodec:run_time,io.netty.handler.codec.http2.Http2ConnectionHandler:run_time,io.netty.handler.codec.http2.DefaultHttp2FrameWriter:run_time' \
'-H:ClassInitialization@jar:file:///home/app/libs/netty-codec-http-4.1.72.Final.jar!/META-INF/native-image/io.netty/codec-http/native-image.properties=io.netty:build_time' \
'-H:ClassInitialization@jar:file:///home/app/libs/netty-codec-http-4.1.72.Final.jar!/META-INF/native-image/io.netty/codec-http/native-image.properties=io.netty.handler.codec.http.HttpObjectEncoder:run_time,io.netty.handler.codec.http.websocketx.WebSocket00FrameEncoder:run_time,io.netty.handler.codec.http.websocketx.extensions.compression.DeflateDecoder:run_time,io.netty.handler.codec.compression.BrotliDecoder:run_time' \
'-H:ClassInitialization@jar:file:///home/app/libs/netty-handler-4.1.72.Final.jar!/META-INF/native-image/io.netty/handler/native-image.properties=io.netty.handler.ssl.util.ThreadLocalInsecureRandom:run_time' \
'-H:ReflectionConfigurationResources@jar:file:///home/app/libs/netty-transport-4.1.72.Final.jar!/META-INF/native-image/io.netty/transport/native-image.properties=META-INF/native-image/io.netty/transport/reflection-config.json' \
'-H:ClassInitialization@jar:file:///home/app/libs/netty-buffer-4.1.72.Final.jar!/META-INF/native-image/io.netty/buffer/native-image.properties=io.netty.buffer.PooledByteBufAllocator:run_time,io.netty.buffer.ByteBufAllocator:run_time,io.netty.buffer.ByteBufUtil:run_time,io.netty.buffer.AbstractReferenceCountedByteBuf:run_time' \
'-H:ClassInitialization@jar:file:///home/app/libs/micronaut-core-reactive-3.2.4.jar!/META-INF/native-image/io.micronaut/micronaut-core-reactive/native-image.properties=io.micronaut.core.async.publisher.Publishers:run_time' \
'-H:ReflectionConfigurationResources@jar:file:///home/app/libs/micronaut-core-reactive-3.2.4.jar!/META-INF/native-image/io.micronaut/micronaut-core-reactive/reflect-config.json=META-INF/native-image/io.micronaut/micronaut-core-reactive/reflect-config.json' \
'-H:ClassInitialization@jar:file:///home/app/libs/micronaut-core-3.2.4.jar!/META-INF/native-image/io.micronaut/micronaut-core/native-image.properties=io.micronaut.core.io.socket.SocketUtils:run_time' \
'-H:ReflectionConfigurationResources@jar:file:///home/app/libs/micronaut-core-3.2.4.jar!/META-INF/native-image/io.micronaut/micronaut-core/reflect-config.json=META-INF/native-image/io.micronaut/micronaut-core/reflect-config.json' \
'-H:ClassInitialization@jar:file:///home/app/libs/netty-common-4.1.72.Final.jar!/META-INF/native-image/io.netty/common/native-image.properties=io.netty.util.AbstractReferenceCounted:run_time,io.netty.util.concurrent.GlobalEventExecutor:run_time,io.netty.util.concurrent.ImmediateEventExecutor:run_time,io.netty.util.concurrent.ScheduledFutureTask:run_time,io.netty.util.internal.ThreadLocalRandom:run_time' \
'-H:ClassInitialization@jar:file:///home/app/libs/netty-common-4.1.72.Final.jar!/META-INF/native-image/io.netty/common/native-image.properties=io.netty.util.NetUtilSubstitutions$NetUtilLocalhost4LazyHolder:run_time' \
'-H:ClassInitialization@jar:file:///home/app/libs/netty-common-4.1.72.Final.jar!/META-INF/native-image/io.netty/common/native-image.properties=io.netty.util.NetUtilSubstitutions$NetUtilLocalhost6LazyHolder:run_time' \
'-H:ClassInitialization@jar:file:///home/app/libs/netty-common-4.1.72.Final.jar!/META-INF/native-image/io.netty/common/native-image.properties=io.netty.util.NetUtilSubstitutions$NetUtilLocalhostLazyHolder:run_time' \
-H:FallbackThreshold=0 \
-H:Name=application \
-H:ConfigurationFileDirectories=/home/app/config-dirs/generateResourcesConfigFile \
-H:Class=com.example.Application \
-H:ClassInitialization=com.fasterxml.jackson.dataformat.xml.util.StaxUtil:run_time \
-H:CLibraryPath=/usr/lib64/graalvm/graalvm21-ce-java17/lib/svm/clibraries/linux-amd64
]
[application:27] classlist: 1,676.69 ms, 0.96 GB
[application:27] (cap): 556.53 ms, 0.96 GB
[application:27] setup: 2,119.39 ms, 0.96 GB
To see how the classes got initialized, use --trace-class-initialization=org.codehaus.stax2.typed.Base64Variants
[application:27] analysis: 30,007.57 ms, 5.28 GB
Error: Classes that should be initialized at run time got initialized during image building:
org.codehaus.stax2.typed.Base64Variants was unintentionally initialized at build time. To see why org.codehaus.stax2.typed.Base64Variants got initialized use --trace-class-initialization=org.codehaus.stax2.typed.Base64Variants
Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
[application:27] [total]: 34,071.49 ms, 5.28 GB
# Printing build artifacts to: /home/app/application.build_artifacts.txt
Error: Image build request failed with exit status 1
com.oracle.svm.driver.NativeImage$NativeImageError: Image build request failed with exit status 1
at com.oracle.svm.driver.NativeImage.showError(NativeImage.java:1762)
at com.oracle.svm.driver.NativeImage.build(NativeImage.java:1473)
at com.oracle.svm.driver.NativeImage.performBuild(NativeImage.java:1434)
at com.oracle.svm.driver.NativeImage.main(NativeImage.java:1421)
I've also tried building the native image locally without Docker using JDK17 and it works.
Ok, I will wait a week until GraalVM 22.0 will be released, maybe it will be fixed there. Thank you very much for your help :)
Maybe there is an error with the current JDK11 GraalVM Docker image, not sure. In any case I've reported this https://github.com/micronaut-projects/micronaut-gradle-plugin/issues/362
I think this is fixed currently.
Expected Behavior
Native image build works.
Actual Behaviour
Steps To Reproduce
Just include this module in
build.gradle
.Environment Information
No response
Example Application
No response
Version
3.2.4