Hello Spring Team,
I would like to reach out with a small issue, hope this is not a trouble. I am trying to build a basic springboot 3.2.4 app with GraalVM21. I am trying to build a native image, not a regular image.
In my pom, I have the following:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.4</version>
<relativePath/>
</parent>
<dependencies>
<dependency>
<groupId>io.projectreactor.kafka</groupId>
<artifactId>reactor-kafka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core-micrometer</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-exporter-otlp</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-otlp</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-statsd</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing-bridge-otel</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-context</artifactId>
<version>4.1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
And I am trying to build via command: mvn -Pnative spring-boot:build-image
Reproducible 100%, my build fails with:
[INFO] [creator] [2/8] Performing analysis... [*****] (23.9s @ 6.32GB)
[INFO] [creator] 26,319 reachable types (90.8% of 29,000 total)
[INFO] [creator] 44,503 reachable fields (61.3% of 72,551 total)
[INFO] [creator] 132,144 reachable methods (60.9% of 216,840 total)
[INFO] [creator] 8,115 types, 1,367 fields, and 8,177 methods registered for reflection
[INFO] [creator] 89 types, 92 fields, and 65 methods registered for JNI access
[INFO] [creator] 4 native libraries: dl, pthread, rt, z
[INFO] [creator] [3/8] Building universe... (8.1s @ 3.78GB)
[INFO] [creator] [4/8] Parsing methods... [**] (2.2s @ 8.80GB)
[INFO] [creator] [5/8] Inlining methods... [***] (1.6s @ 4.12GB)
[INFO] [creator] [6/8] Compiling methods... [****] (12.1s @ 8.28GB)
[INFO] [creator] [7/8] Layouting methods... [***] (10.9s @ 3.25GB)
[INFO] [creator]
[INFO] [creator] [8/8] Creating image... [**] (0.0s @ 3.47GB)
[INFO] [creator] --------------------------------------------------------------------------------
[INFO] [creator] 3.9s (5.5% of total time) in 33 GCs | Peak RSS: 13.04GB | CPU load: 16.31
[INFO] [creator] --------------------------------------------------------------------------------
[INFO] [creator] Produced artifacts:
[INFO] [creator] /layers/paketo-buildpacks_native-image/native-image/svm_err_b_20240404T040143.347_pid331.md (build_info)
[INFO] [creator] ================================================================================
[INFO] [creator] Failed generating 'com.myApplication' after 1m 9s.
[INFO] [creator]
[INFO] [creator] The build process encountered an unexpected error:
[INFO] [creator]
[INFO] [creator] > com.oracle.svm.core.util.VMError$HostedError: com.oracle.svm.core.util.UserError$UserException: Image heap writing found a class not seen during static analysis. Did a static field or an object referenced from a static field change during native image generation? For example, a lazily initialized cache could have been initialized during image generation, in which case you need to force eager initialization of the cache before static analysis or reset the cache using a field value recomputation.
[INFO] [creator] class: io.opentelemetry.sdk.common.export.RetryPolicy
[INFO] [creator] reachable through:
[INFO] [creator] object: [Ljava.lang.Class;@566717a0 of class: java.lang.Class[]
[INFO] [creator] object: com.oracle.svm.core.code.ImageCodeInfo@3ae14048 of class: com.oracle.svm.core.code.ImageCodeInfo
[INFO] [creator] root: com.oracle.svm.core.code.ImageCodeInfo.prepareCodeInfo()
[INFO] [creator]
[INFO] [creator]
[INFO] [creator] Please inspect the generated error report at:
[INFO] [creator] /layers/paketo-buildpacks_native-image/native-image/svm_err_b_20240404T040143.347_pid331.md
[INFO] [creator]
[INFO] [creator] If you are unable to resolve this problem, please file an issue with the error report at:
[INFO] [creator] https://bell-sw.com/support
[INFO] [creator] unable to invoke layer creator
[INFO] [creator] unable to contribute native-image layer
[INFO] [creator] error running build
[INFO] [creator] exit status 1
[INFO] [creator] ERROR: failed to build: exit status 1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:39 min
[INFO] Finished at: 2024-04-04T04:01:44Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.2.4:build-image (default-cli) on project myapp: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:3.2.4:build-image failed: Builder lifecycle 'creator' failed with status code 51 -> [Help 1]
My sincere apologies, but I am not sure what is the root cause of this error.
I tried building a non-native image instead, with the command mvn spring-boot:build-image and the build will succeed, with the container running fine.
Could you please help on this issue?
Thank you and wish you a good day.