quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.78k stars 2.68k forks source link

Buildpack leading to NET4_ANY errors #41801

Closed clockworkmay closed 3 months ago

clockworkmay commented 4 months ago

Describe the bug

Working through a small tutorial which builds properly when I run mvnw clean install -Dnative "-Dquarkus.container-image.build=true" "-Dquarkus.native.container-build=true" "-Dquarkus.buildpack.builder-env.BP_JVM_VERSION=17" (though it does oddly lead to a larger executable that uses more memory in Docker, but I will file a separate issue for that).

The build also works correctly without native compile in buildpack: pack build rest-api-java-buildpacknative --path .\ --builder paketobuildpacks/builder-jammy-tiny

However, when I try to build to native container, I am unable to complete the build. I wasn't able to find a similar issue, but if there is something similar, please let me know. Thank you.

Expected behavior

Build successfully

Actual behavior

Error stack and context:

Paketo Buildpack for Native Image 5.14.1
  https://github.com/paketo-buildpacks/native-image
  Build Configuration:
    $BP_BINARY_COMPRESSION_METHOD          Compression mechanism used to reduce binary size. Options: `none` (default), `upx` or `gzexe`
    $BP_NATIVE_IMAGE                       enable native image build
    $BP_NATIVE_IMAGE_BUILD_ARGUMENTS       arguments to pass to the native-image command
    $BP_NATIVE_IMAGE_BUILD_ARGUMENTS_FILE  a file with arguments to pass to the native-image command
    $BP_NATIVE_IMAGE_BUILT_ARTIFACT        the built application artifact explicitly, required if building from a JAR
  Command "packages" is deprecated, use `syft scan` instead
  Native Image: Contributing to layer
    Executing native-image --no-fallback -H:+StaticExecutableWithDynamicLibC -H:Name=/layers/paketo-buildpacks_native-image/native-image/io.quarkus.runner.GeneratedMain -cp /workspace: io.quarkus.runner.GeneratedMain
Warning: The option '-H:+StaticExecutableWithDynamicLibC' is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in the future.
Warning: The option '-H:Name=/layers/paketo-buildpacks_native-image/native-image/io.quarkus.runner.GeneratedMain' is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in the future.
Warning: Please re-evaluate whether any experimental option is required, and either remove or unlock it. The build output lists all active experimental options, including where they come from and possible alternatives. If you think an experimental option should be considered as stable, please file an issue.
================================================================================
GraalVM Native Image: Generating 'io.quarkus.runner.GeneratedMain' (executable)...
================================================================================
For detailed information and explanations on the build output, visit:
https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/BuildOutput.md
--------------------------------------------------------------------------------
Jul 10, 2024 3:52:46 AM org.jboss.logmanager.JBossLoggerFinder getLogger
ERROR: The LogManager accessed before the "java.util.logging.manager" system property was set to "org.jboss.logmanager.LogManager". Results may be unexpected.
[1/8] Initializing...                                            (7.3s @ 0.20GB)
 Java version: 21.0.3+7-LTS, vendor version: Oracle GraalVM 21.0.3+7.1
 Graal compiler: optimization level: 2, target machine: x86-64-v3, PGO: ML-inferred
 C compiler: gcc (linux, x86_64, 11.4.0)
 Garbage collector: Serial GC (max heap size: 80% of RAM)
 2 user-specific feature(s):
 - com.oracle.svm.thirdparty.gson.GsonFeature
 - org.eclipse.angus.activation.nativeimage.AngusActivationFeature
--------------------------------------------------------------------------------
 2 experimental option(s) unlocked:
 - '-H:Name' (alternative API option(s): -o io.quarkus.runner.GeneratedMain; origin(s): command line)
 - '-H:+StaticExecutableWithDynamicLibC' (origin(s): command line)
--------------------------------------------------------------------------------
Build resources:
 - 5.80GB of memory (75.6% of 7.67GB system memory, determined at start)
 - 12 thread(s) (100.0% of 12 available processor(s), determined at start)
[2/8] Performing analysis...  []                                (21.6s @ 0.74GB)
    8,046 reachable types   (72.7% of   11,063 total)
    9,907 reachable fields  (52.9% of   18,740 total)
   36,152 reachable methods (42.9% of   84,278 total)
    3,081 types,   141 fields, and 4,148 methods registered for reflection

2 fatal errors detected:
Fatal error: com.oracle.graal.pointsto.util.AnalysisError$ParsingError: Error encountered while parsing io.quarkus.runtime.configuration.CidrAddressConverter.convert(CidrAddressConverter.java:23)
Parsing context:
   at io.quarkus.runtime.configuration.CidrAddressConverter.convert(CidrAddressConverter.java:16)
   at io.smallrye.config.Converters$OptionalConverter.convert(Converters.java:839)
   at io.smallrye.config.Converters$OptionalConverter.convert(Converters.java:825)
   at io.smallrye.config.inject.ConfigProducerUtil.lambda$convertMapValues$1(ConfigProducerUtil.java:132)
   at io.smallrye.config.inject.ConfigProducerUtil$$Lambda/0x00000007c2455f78.apply(Unknown Source)
   at io.smallrye.config.inject.ConfigProducerUtil$MapKeyConverter.convert(ConfigProducerUtil.java:378)
   at io.smallrye.config.inject.ConfigProducerUtil$MapKeyConverter.convert(ConfigProducerUtil.java:360)
   at io.smallrye.config.inject.ConfigProducerUtil.convertMapValues(ConfigProducerUtil.java:138)
   at io.smallrye.config.inject.ConfigProducerUtil.getValue(ConfigProducerUtil.java:97)
   at io.quarkus.arc.runtime.ConfigRecorder.validateConfigProperties(ConfigRecorder.java:60)
   at io.quarkus.deployment.steps.ConfigBuildStep$validateStaticInitConfigProperty682828288.deploy_0(Unknown Source)
   at io.quarkus.deployment.steps.ConfigBuildStep$validateStaticInitConfigProperty682828288.deploy(Unknown Source)
   at io.quarkus.runner.ApplicationImpl.<clinit>(Unknown Source)
   at static root method.(Unknown Source)

        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.AnalysisError.parsingError(AnalysisError.java:149)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.createFlowsGraph(MethodTypeFlow.java:184)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.ensureFlowsGraphCreated(MethodTypeFlow.java:153)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.getOrCreateMethodFlowsGraphInfo(MethodTypeFlow.java:111)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.typestate.DefaultVirtualInvokeTypeFlow.onObservedUpdate(DefaultVirtualInvokeTypeFlow.java:114)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.TypeFlow.update(TypeFlow.java:620)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.PointsToAnalysis$1.run(PointsToAnalysis.java:491)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.executeCommand(CompletionExecutor.java:187)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.lambda$executeService$0(CompletionExecutor.java:171)
        at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1423)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
Caused by: org.graalvm.compiler.java.BytecodeParser$BytecodeParserError: com.oracle.svm.core.util.VMError$HostedError: Error in @InjectAccessors handling of field org.wildfly.common.net.Inet.INET4_ANY, accessors class io.quarkus.runtime.graal.Inet4AnyAccessor: found no method named set or setINET4_ANY
        at parsing org.wildfly.common.net.Inet.<clinit>(Inet.java:54)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.throwParserError(BytecodeParser.java:2553)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.throwParserError(SharedGraphBuilderPhase.java:182)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3434)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.iterateBytecodesForBlock(SharedGraphBuilderPhase.java:743)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.handleBytecodeBlock(BytecodeParser.java:3386)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:3228)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.build(BytecodeParser.java:1137)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.build(SharedGraphBuilderPhase.java:162)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:1029)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.GraphBuilderPhase$Instance.run(GraphBuilderPhase.java:101)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase.run(SharedGraphBuilderPhase.java:116)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.run(Phase.java:49)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:434)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:42)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:38)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.AnalysisParsedGraph.parseBytecode(AnalysisParsedGraph.java:146)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.parseGraph(AnalysisMethod.java:895)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsedHelper(AnalysisMethod.java:860)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsed(AnalysisMethod.java:843)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.classinitialization.SimulateClassInitializerSupport.decodeGraph(SimulateClassInitializerSupport.java:467)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.classinitialization.SimulateClassInitializerSupport.addClassInitializerDependencies(SimulateClassInitializerSupport.java:453)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.classinitialization.SimulateClassInitializerSupport.trySimulateClassInitializer(SimulateClassInitializerSupport.java:363)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.classinitialization.SimulateClassInitializerSupport.trySimulateClassInitializer(SimulateClassInitializerSupport.java:217)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.InlineBeforeAnalysisGraphDecoderImpl.handleEnsureClassInitializedNode(InlineBeforeAnalysisGraphDecoderImpl.java:82)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.InlineBeforeAnalysisGraphDecoderImpl.doCanonicalizeFixedNode(InlineBeforeAnalysisGraphDecoderImpl.java:55)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.phases.InlineBeforeAnalysisGraphDecoder.canonicalizeFixedNode(InlineBeforeAnalysisGraphDecoder.java:215)
        at jdk.internal.vm.compiler/org.graalvm.compiler.nodes.SimplifyingGraphDecoder.handleFixedNode(SimplifyingGraphDecoder.java:194)
        at jdk.internal.vm.compiler/org.graalvm.compiler.nodes.GraphDecoder.processNextNode(GraphDecoder.java:928)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.phases.InlineBeforeAnalysisGraphDecoder.processNextNode(InlineBeforeAnalysisGraphDecoder.java:378)
        at jdk.internal.vm.compiler/org.graalvm.compiler.nodes.GraphDecoder.decode(GraphDecoder.java:650)
        at jdk.internal.vm.compiler/org.graalvm.compiler.replacements.PEGraphDecoder.decode(PEGraphDecoder.java:892)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.phases.InlineBeforeAnalysis.decodeGraph(InlineBeforeAnalysis.java:76)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:195)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:621)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.createFlowsGraph(MethodTypeFlow.java:167)
        ... 13 more
Caused by: com.oracle.svm.core.util.VMError$HostedError: Error in @InjectAccessors handling of field org.wildfly.common.net.Inet.INET4_ANY, accessors class io.quarkus.runtime.graal.Inet4AnyAccessor: found no method named set or setINET4_ANY
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:78)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.InjectedAccessorsPlugin.error(InjectedAccessorsPlugin.java:152)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.InjectedAccessorsPlugin.handleField(InjectedAccessorsPlugin.java:89)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.InjectedAccessorsPlugin.handleStoreStaticField(InjectedAccessorsPlugin.java:62)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genPutStatic(BytecodeParser.java:5013)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genPutStatic(BytecodeParser.java:4986)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBytecode(BytecodeParser.java:5411)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3426)
        ... 45 more
Fatal error: org.graalvm.compiler.debug.GraalError: com.oracle.graal.pointsto.util.AnalysisError: parsing had failed in another thread
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.AnalysisFuture.setException(AnalysisFuture.java:49)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:322)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.AnalysisFuture.ensureDone(AnalysisFuture.java:63)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.analysis.NativeImagePointsToAnalysis.lambda$onTypeReachable$0(NativeImagePointsToAnalysis.java:119)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.executeCommand(CompletionExecutor.java:187)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.lambda$executeService$0(CompletionExecutor.java:171)
        at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1423)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
Caused by: com.oracle.graal.pointsto.util.AnalysisError: parsing had failed in another thread
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.AnalysisError.shouldNotReachHere(AnalysisError.java:173)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsedHelper(AnalysisMethod.java:871)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsed(AnalysisMethod.java:843)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.classinitialization.SimulateClassInitializerSupport.decodeGraph(SimulateClassInitializerSupport.java:467)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.classinitialization.SimulateClassInitializerSupport.addClassInitializerDependencies(SimulateClassInitializerSupport.java:453)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.classinitialization.SimulateClassInitializerSupport.trySimulateClassInitializer(SimulateClassInitializerSupport.java:363)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.classinitialization.SimulateClassInitializerSupport.trySimulateClassInitializer(SimulateClassInitializerSupport.java:217)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.analysis.DynamicHubInitializer.buildClassInitializationInfo(DynamicHubInitializer.java:196)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.analysis.DynamicHubInitializer.initializeMetaData(DynamicHubInitializer.java:106)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.analysis.NativeImagePointsToAnalysis.initializeMetaData(NativeImagePointsToAnalysis.java:124)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisUniverse.initializeMetaData(AnalysisUniverse.java:706)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisType.lambda$new$1(AnalysisType.java:311)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
        ... 10 more
Caused by: org.graalvm.compiler.java.BytecodeParser$BytecodeParserError: com.oracle.svm.core.util.VMError$HostedError: Error in @InjectAccessors handling of field org.wildfly.common.net.Inet.INET4_ANY, accessors class io.quarkus.runtime.graal.Inet4AnyAccessor: found no method named set or setINET4_ANY
        at parsing org.wildfly.common.net.Inet.<clinit>(Inet.java:54)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.throwParserError(BytecodeParser.java:2553)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.throwParserError(SharedGraphBuilderPhase.java:182)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3434)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.iterateBytecodesForBlock(SharedGraphBuilderPhase.java:743)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.handleBytecodeBlock(BytecodeParser.java:3386)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:3228)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.build(BytecodeParser.java:1137)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.build(SharedGraphBuilderPhase.java:162)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:1029)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.GraphBuilderPhase$Instance.run(GraphBuilderPhase.java:101)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase.run(SharedGraphBuilderPhase.java:116)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.run(Phase.java:49)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:434)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:42)
        at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:38)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.AnalysisParsedGraph.parseBytecode(AnalysisParsedGraph.java:146)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.parseGraph(AnalysisMethod.java:895)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsedHelper(AnalysisMethod.java:860)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsed(AnalysisMethod.java:843)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.classinitialization.SimulateClassInitializerSupport.decodeGraph(SimulateClassInitializerSupport.java:467)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.classinitialization.SimulateClassInitializerSupport.addClassInitializerDependencies(SimulateClassInitializerSupport.java:453)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.classinitialization.SimulateClassInitializerSupport.trySimulateClassInitializer(SimulateClassInitializerSupport.java:363)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.classinitialization.SimulateClassInitializerSupport.trySimulateClassInitializer(SimulateClassInitializerSupport.java:217)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.InlineBeforeAnalysisGraphDecoderImpl.handleEnsureClassInitializedNode(InlineBeforeAnalysisGraphDecoderImpl.java:82)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.InlineBeforeAnalysisGraphDecoderImpl.doCanonicalizeFixedNode(InlineBeforeAnalysisGraphDecoderImpl.java:55)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.phases.InlineBeforeAnalysisGraphDecoder.canonicalizeFixedNode(InlineBeforeAnalysisGraphDecoder.java:215)
        at jdk.internal.vm.compiler/org.graalvm.compiler.nodes.SimplifyingGraphDecoder.handleFixedNode(SimplifyingGraphDecoder.java:194)
        at jdk.internal.vm.compiler/org.graalvm.compiler.nodes.GraphDecoder.processNextNode(GraphDecoder.java:928)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.phases.InlineBeforeAnalysisGraphDecoder.processNextNode(InlineBeforeAnalysisGraphDecoder.java:378)
        at jdk.internal.vm.compiler/org.graalvm.compiler.nodes.GraphDecoder.decode(GraphDecoder.java:650)
        at jdk.internal.vm.compiler/org.graalvm.compiler.replacements.PEGraphDecoder.decode(PEGraphDecoder.java:892)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.phases.InlineBeforeAnalysis.decodeGraph(InlineBeforeAnalysis.java:76)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:195)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:621)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.createFlowsGraph(MethodTypeFlow.java:167)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.ensureFlowsGraphCreated(MethodTypeFlow.java:153)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.getOrCreateMethodFlowsGraphInfo(MethodTypeFlow.java:111)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.typestate.DefaultVirtualInvokeTypeFlow.onObservedUpdate(DefaultVirtualInvokeTypeFlow.java:114)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.TypeFlow.update(TypeFlow.java:620)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.PointsToAnalysis$1.run(PointsToAnalysis.java:491)
        ... 8 more
Caused by: com.oracle.svm.core.util.VMError$HostedError: Error in @InjectAccessors handling of field org.wildfly.common.net.Inet.INET4_ANY, accessors class io.quarkus.runtime.graal.Inet4AnyAccessor: found no method named set or setINET4_ANY
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:78)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.InjectedAccessorsPlugin.error(InjectedAccessorsPlugin.java:152)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.InjectedAccessorsPlugin.handleField(InjectedAccessorsPlugin.java:89)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.InjectedAccessorsPlugin.handleStoreStaticField(InjectedAccessorsPlugin.java:62)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genPutStatic(BytecodeParser.java:5013)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genPutStatic(BytecodeParser.java:4986)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBytecode(BytecodeParser.java:5411)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3426)
        ... 45 more
--------------------------------------------------------------------------------
    5.2s (14.6% of total time) in 76 GCs | Peak RSS: 1.96GB | CPU load: 7.13
================================================================================
Finished generating 'io.quarkus.runner.GeneratedMain' in 29.7s.
unable to invoke layer creator
unable to contribute native-image layer
error running build
exit status 1
ERROR: failed to build: exit status 1
ERROR: failed to build: executing lifecycle: failed with status code: 51

How to Reproduce?

pack build rest-api-java -b paketo-buildpacks/oracle -b urn:cnb:builder:paketo-buildpacks/java-native-image --builder paketobuildpacks/builder-jammy-tiny --env BP_MAVEN_ACTIVE_PROFILES=native --env "BP_JVM_VERSION=21"

or

pack build rest-api-java-buildpacknative --path .\ --builder paketobuildpacks/builder-jammy-tiny --buildpack paketo-buildpacks/java-native-image --env "BP_JVM_VERSION=21" --env BP_MAVEN_ACTIVE_PROFILES=native

both leads to the error stack above. Targeting JDK 17 vs 21 results in the same error.

Using the default --builder paketobuildpacks/builder:tiny seems to indicate that JDK Native 21 isn't supported yet: no valid dependencies for native-image-svm, 21, and io.paketo.stacks.tiny in [(jdk, 8.0.372, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (jre, 8.0.372, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (jdk, 11.0.19, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (jre, 11.0.19, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (native-image-svm, 11.0.19, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (jdk, 17.0.7, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (jre, 17.0.7, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (native-image-svm, 17.0.7, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (jdk, 20.0.1, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (jre, 20.0.1, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *])]

Output of uname -a or ver

Windows 11

Output of java -version

liberica 21.0.3-12

Mandrel or GraalVM version (if different from Java)

Oracle GraalVM 21.0.3+7.1 (build 21.0.3+7-LTS-jvmci-23.1-b37)

Quarkus version or git rev

3.12.0

Build tool (ie. output of mvnw --version or gradlew --version)

3.9.7 (via Scoop)

Additional information

pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.testing</groupId>
    <artifactId>rest-api-java</artifactId>
    <version>1.0.3-native</version>

    <properties>
        <java.version>21</java.version>
        <maven.compiler.release>21</maven.compiler.release>
        <compiler-plugin.version>3.13.0</compiler-plugin.version>
        <jpastreamer.version>3.0.3.Final</jpastreamer.version>
        <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
        <quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
        <quarkus.platform.version>3.12.0</quarkus.platform.version>
        <surefire-plugin.version>3.2.5</surefire-plugin.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>${quarkus.platform.group-id}</groupId>
                <artifactId>${quarkus.platform.artifact-id}</artifactId>
                <version>${quarkus.platform.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-arc</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-hibernate-orm-panache</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-jdbc-postgresql</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkiverse.jpastreamer</groupId>
            <artifactId>quarkus-jpastreamer</artifactId>
            <version>${jpastreamer.version}</version>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-container-image-buildpack</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-junit5</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-rest-jackson</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-smallrye-openapi</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${compiler-plugin.version}</version>
                <configuration>
                    <compilerArgs>
                        <arg>-parameters</arg>
                    </compilerArgs>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>${surefire-plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <systemPropertyVariables>
                        <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
                        <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                        <maven.home>${maven.home}</maven.home>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${surefire-plugin.version}</version>
                <configuration>
                    <systemPropertyVariables>
                        <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                        <maven.home>${maven.home}</maven.home>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
            <plugin>
                <groupId>${quarkus.platform.group-id}</groupId>
                <artifactId>quarkus-maven-plugin</artifactId>
                <version>${quarkus.platform.version}</version>
                <extensions>true</extensions>
                <executions>
                    <execution>
                        <goals>
                            <goal>build</goal>
                            <goal>generate-code</goal>
                            <goal>generate-code-tests</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>native</id>
            <activation>
                <property>
                    <name>native</name>
                </property>
            </activation>
            <properties>
                <skipITs>false</skipITs>
                <quarkus.package.jar.type>uber-jar</quarkus.package.jar.type>
                <quarkus.native.enabled>true</quarkus.native.enabled>
            </properties>
        </profile>
    </profiles>
</project>
quarkus-bot[bot] commented 4 months ago

/cc @Karm (mandrel), @galderz (mandrel), @geoand (knative), @iocanel (knative), @zakkak (mandrel)

geoand commented 4 months ago

@radcortez I'm surprised this has not been an issue before

radcortez commented 4 months ago

Hum... very strange. Look at the reported class: https://github.com/quarkusio/quarkus/blob/ebee0a4b66d1b4dba9c51165e78d22fbf3b90d3e/core/runtime/src/main/java/io/quarkus/runtime/configuration/CidrAddressConverter.java

The line numbers reported in the stacktrace do not make sense. Also, this class was last touched with the Jakarta rename.

geoand commented 4 months ago

Very weird indeed...

radcortez commented 4 months ago

@clockworkmay can you please also share the tutorial code in a small reproducer? From the stacktrace it seems you have something like:

@ConfigProperty(...)
Optional<CidrAddress> cidrAddress;

Which should work (I've just tried it). We need the full code to properly assess the problem. Thank you!

dmlloyd commented 4 months ago

I wonder if we should remove io.quarkus.runtime.graal.Target_org_wildfly_common_net_Inet and instead mark Inet as rerun-initialization instead. It's failing while looking for a write-accessor on Inet for fields which are static-final, which makes me wonder if it is already trying to rerun static init for some reason? Maybe only when CidrAddress is reachable?

In any case, GraalVM did (at one point, maybe still) forbid instances of InetAddress from being on the build time heap. This may mean that one cannot build a native image with "build time run time fixed" configuration properties of that type or any type that contains that type (e.g. CidrAddress). A workaround could be to make the property in question be run time config instead.

clockworkmay commented 4 months ago

Yes, of course. The code came mostly from the Quarkus Configurator and is using the following packages:

I also am not sure where the cidrAddress is being called. I am assuming from one of the libraries. A global search in Intellj for cidrAddress is coming up empty. I've pushed the code to Github (pardon the hardcoded database passwords, I'll slowly make my way to better security measures):

git clone https://github.com/clockworkmay/rest-api-java.git
cd rest-api-java
pack build rest-api-java-buildpacknative --path .\ --env BP_MAVEN_ACTIVE_PROFILES=native --builder paketobuildpacks/builder-jammy-tiny --buildpack paketo-buildpacks/java-native-image --env "BP_JVM_VERSION=21"  
radcortez commented 3 months ago

I did try your reproducer with a native local build, and it worked as expected. I've also built the native image with the quarkus cli and docker with no issues.

I did try with pack and noticed a successful native image build in Paketo Buildpack for Maven 6.17.3 and a failed second native image build in Paketo Buildpack for Native Image 5.14.1. What puzzles me is that while I get the same error as you, the reported line is different but still does not make any sense with the actual code.

We may be able to fix it with @dmlloyd recommendation, but I also feel that there is some issue with how pack builds the native image.

clockworkmay commented 3 months ago

@radcortez thank you for the follow up.

In case it matters, pack build test_javanativeimage --path . --builder paketobuildpacks/builder-jammy-tiny --buildpack paketo-buildpacks/java-native-image --env "BP_JVM_VERSION=21" --env "BP_MAVEN_ACTIVE_PROFILES=native" --env "BP_NATIVE_IMAGE=true" uses

===> DETECTING
target distro name/version labels not found, reading /etc/os-release file
7 of 15 buildpacks participating
paketo-buildpacks/ca-certificates   3.8.2
paketo-buildpacks/bellsoft-liberica 10.8.1
paketo-buildpacks/syft              1.47.1
paketo-buildpacks/maven             6.17.3
paketo-buildpacks/executable-jar    6.10.1
paketo-buildpacks/spring-boot       5.30.1
paketo-buildpacks/native-image      5.14.1

on my machine, in case that matters.

I'm not too attached to any of the process and am not too knowledgeable about docker or web deployment myself at the moment. I'm mainly using pack because I was following this tutorial (https://www.codecentric.de/wissens-hub/blog/spring-boot-flyio), need containers to use Fly.io, and want to build to native to reduce the memory/size footprint. My only real attachment is to Java, since that's what I know. Is the recommend route to use docker?

I wasn't able to get a container native build working with Maven 6.17.3 though. pack build test_maven --path . --builder paketobuildpacks/builder-jammy-tiny --buildpack paketo-buildpacks/maven --env "BP_JVM_VERSION=21" --env "BP_MAVEN_ACTIVE_PROFILES=native" --env "BP_NATIVE_IMAGE=true" gets me a

===> DETECTING
target distro name/version labels not found, reading /etc/os-release file
======== Results ========
pass: paketo-buildpacks/maven@6.17.3
pass: paketo-buildpacks/syft@1.47.1
Resolving plan... (try #1)
fail: paketo-buildpacks/maven@6.17.3 requires jdk
Resolving plan... (try #2)
fail: paketo-buildpacks/maven@6.17.3 requires syft
Resolving plan... (try #3)
fail: paketo-buildpacks/maven@6.17.3 requires syft
ERROR: No buildpack groups passed detection.
ERROR: Please check that you are running against the correct path.
ERROR: failed to detect: no buildpacks participating
ERROR: failed to build: executing lifecycle: failed with status code: 20

that I've been trying to resolve.

radcortez commented 3 months ago

What we recommend is our guide to building a native executable that will work: https://quarkus.io/guides/building-native-image

We don't really control what other tools like pack do the build. An issue has to be filled on their side. If they can show us that it is our problem, we will happily fix it.