-
Notifications
You must be signed in to change notification settings - Fork 15
Description
Expected Behavior
I created a project using micronaut launcher with HTTP-POJA as a feature and maven as the build tool. The project is attached here with. It fails to produce native-image.
Actual Behaviour
`
GraalVM Native Image: Generating 'http-handler-mn-osx-aarch_64-1.0-SNAPSHOT' (executable)...
[1/8] Initializing... (5.7s @ 0.19GB)
Java version: 25.0.1+8-LTS, vendor version: Oracle GraalVM 25.0.1+8.1
Graal compiler: optimization level: b, target machine: armv8.1-a, PGO: off
C compiler: cc (apple, arm64, 17.0.0)
Garbage collector: Serial GC (max heap size: 80% of RAM)
2 user-specific feature(s):
- com.oracle.svm.thirdparty.gson.GsonFeature
- io.micronaut.core.io.service.ServiceLoaderFeature
Build resources:
- 27.51GB of memory (40.0% of system memory, using available memory)
- 10 thread(s) (100.0% of 10 available processor(s), determined at start)
[2/8] Performing analysis... [] (5.2s @ 0.50GB)
4,809 types, 4,440 fields, and 19,819 methods found reachable
1,983 types, 158 fields, and 1,923 methods registered for reflection
0 downcalls and 0 upcalls registered for foreign access
Fatal error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: An object of type 'io.micronaut.context.ApplicationContextConfigurer$1' was found in the image heap. This type, however, is marked for initialization at image run time for the following reason: classes are initialized at run time by default.
This is not allowed for correctness reasons: All objects that are stored in the image heap must be initialized at build time.
You now have two options to resolve this:
-
If it is intended that objects of type 'io.micronaut.context.ApplicationContextConfigurer$1' are persisted in the image heap, add
'--initialize-at-build-time=io.micronaut.context.ApplicationContextConfigurer$1'
to the native-image arguments. Note that initializing new types can store additional objects to the heap. It is advised to check the static fields of 'io.micronaut.context.ApplicationContextConfigurer$1' to see if they are safe for build-time initialization, and that they do not contain any sensitive data that should not become part of the image.
-
If these objects should not be stored in the image heap, you can use
'--trace-object-instantiation=io.micronaut.context.ApplicationContextConfigurer$1'
to find classes that instantiate these objects. Once you found such a class, you can mark it explicitly for run time initialization with
'--initialize-at-run-time=<culprit>'
to prevent the instantiation of the object.
If you are seeing this message after upgrading to a new GraalVM release, this means that some objects ended up in the image heap without their type being marked with --initialize-at-build-time.
To fix this, include '--initialize-at-build-time=io.micronaut.context.ApplicationContextConfigurer$1' in your configuration. If the classes do not originate from your code, it is advised to update all library or framework dependencies to the latest version before addressing this error.
The following detailed trace displays from which field in the code the object was reached.
Object was reached by
scanning root io.micronaut.context.ApplicationContextConfigurer$1@17986d05: io.micronaut.context.ApplicationContextConfigurer$1@17986d05 embedded in
io.micronaut.context.DefaultApplicationContextBuilder.loadApplicationContextCustomizer(DefaultApplicationContextBuilder.java:478)
parsing method io.micronaut.context.DefaultApplicationContextBuilder.loadApplicationContextCustomizer(DefaultApplicationContextBuilder.java:474) reachable via the parsing context
at com.oracle.svm.core.code.FactoryMethodHolder.Micronaut_xN1wMHc5s0DDMgQpk75FdH(generated:0)
at io.micronaut.runtime.Micronaut.build(Micronaut.java:312)
at sahoo.graalos.progmodel.mn.Application.main(Application.java:17)
at com.oracle.svm.core.JavaMainWrapper.invokeMain(JavaMainWrapper.java:189)
at com.oracle.svm.core.JavaMainWrapper.runCore0(JavaMainWrapper.java:232)
at com.oracle.svm.core.JavaMainWrapper.doRun(JavaMainWrapper.java:299)
at com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_XNhh1mz2Ib2aPR1wdv014D(generated:0)
at static root method.(Unknown Source)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageHeapScanner.onObjectReachable(ImageHeapScanner.java:618)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.heap.SVMImageHeapScanner.onObjectReachable(SVMImageHeapScanner.java:127)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageHeapScanner.lambda$markReachable$0(ImageHeapScanner.java:589)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.executeCommand(CompletionExecutor.java:166)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.lambda$executeService$0(CompletionExecutor.java:152)
at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.compute(ForkJoinTask.java:1750)
at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.compute(ForkJoinTask.java:1742)
at java.base/java.util.concurrent.ForkJoinTask$InterruptibleTask.exec(ForkJoinTask.java:1659)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:511)
at java.base/java.util.concurrent.ForkJoinPool.externalHelpQuiesce(ForkJoinPool.java:2509)
at java.base/java.util.concurrent.ForkJoinPool.helpQuiescePool(ForkJoinPool.java:2543)
at java.base/java.util.concurrent.ForkJoinPool.awaitQuiescence(ForkJoinPool.java:4159)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.complete(CompletionExecutor.java:208)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.PointsToAnalysis.doTypeflow(PointsToAnalysis.java:682)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.PointsToAnalysis.finish(PointsToAnalysis.java:648)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.AbstractAnalysisEngine.runAnalysis(AbstractAnalysisEngine.java:160)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:841)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:569)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:534)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:548)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:761)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.start(NativeImageGeneratorRunner.java:163)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:111)
Caused by: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: An object of type 'io.micronaut.context.ApplicationContextConfigurer$1' was found in the image heap. This type, however, is marked for initialization at image run time for the following reason: classes are initialized at run time by default.
This is not allowed for correctness reasons: All objects that are stored in the image heap must be initialized at build time.
You now have two options to resolve this:
-
If it is intended that objects of type 'io.micronaut.context.ApplicationContextConfigurer$1' are persisted in the image heap, add
'--initialize-at-build-time=io.micronaut.context.ApplicationContextConfigurer$1'
to the native-image arguments. Note that initializing new types can store additional objects to the heap. It is advised to check the static fields of 'io.micronaut.context.ApplicationContextConfigurer$1' to see if they are safe for build-time initialization, and that they do not contain any sensitive data that should not become part of the image.
-
If these objects should not be stored in the image heap, you can use
'--trace-object-instantiation=io.micronaut.context.ApplicationContextConfigurer$1'
to find classes that instantiate these objects. Once you found such a class, you can mark it explicitly for run time initialization with
'--initialize-at-run-time=<culprit>'
to prevent the instantiation of the object.
If you are seeing this message after upgrading to a new GraalVM release, this means that some objects ended up in the image heap without their type being marked with --initialize-at-build-time.
To fix this, include '--initialize-at-build-time=io.micronaut.context.ApplicationContextConfigurer$1' in your configuration. If the classes do not originate from your code, it is advised to update all library or framework dependencies to the latest version before addressing this error.
The following detailed trace displays from which field in the code the object was reached.
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.checkImageHeapInstance(ClassInitializationFeature.java:205)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.SVMHost.validateReachableObject(SVMHost.java:371)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageHeapScanner.onObjectReachable(ImageHeapScanner.java:607)
... 22 more
0.4s (3.5% of total time) in 29 GCs | Peak RSS: 1.43GB | CPU load: 5.21
========================================================================================================================
Failed generating 'http-handler-mn-osx-aarch_64-1.0-SNAPSHOT' after 11.3s.
com.oracle.svm.driver.NativeImage$NativeImageError
at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.showError(NativeImage.java:2514)
at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.build(NativeImage.java:2089)
at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.performBuild(NativeImage.java:2048)
at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.main(NativeImage.java:2030)
at java.base@25.0.1/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.910 s
[INFO] Finished at: 2026-01-02T16:45:04-08:00
[INFO] ------------------------------------------------------------------------
`
Steps To Reproduce
- Unzip demo.zip
- ./mvnw package -Dpackaging=native-image -DskipTests=true (You need to use -DskipTests=true due to Test failure for a HTTP-POJA sample created using micronaut launcher #2411)
Environment Information
Apache Maven 3.9.10 (5f519b97e944483d878815739f519b2eade0a91d)
Maven home: /Users/sanjsaho/.m2/wrapper/dists/apache-maven-3.9.10-bin/93fb1152/apache-maven-3.9.10
Java version: 25.0.1, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/graalvm-jdk-25.0.1+8.1/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "15.7.2", arch: "aarch64", family: "mac"
Example Application
No response
Version
4.10.6