quarkusio / quarkus

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

Building native executable fails. #41478

Open portlek opened 5 months ago

portlek commented 5 months ago

Describe the bug

Note: Project is building and running fine in JVM mode. Note2: Building via the docker container has the same result as building locally.

I created a simple quarkus project that has these extensions/dependencies:

implementation("io.quarkus:quarkus-rest")
implementation("io.quarkus:quarkus-reactive-mysql-client")
implementation("io.quarkus:quarkus-jdbc-mariadb")
implementation("io.quarkus:quarkus-smallrye-jwt")
implementation("io.quarkus:quarkus-arc")

testImplementation("io.quarkus:quarkus-junit5")
testImplementation("io.rest-assured:rest-assured")

Then run this command: build -x test -Dquarkus.package.jar.enabled=false -Dquarkus.native.enabled=true

The build fails with this log:

18:26:53: Executing 'build -x test -Dquarkus.package.jar.enabled=false -Dquarkus.native.enabled=true'...

> Task :buildSrc:checkKotlinGradlePluginConfigurationErrors
> Task :buildSrc:compileKotlin UP-TO-DATE
> Task :buildSrc:compileJava NO-SOURCE
> Task :buildSrc:compileGroovy NO-SOURCE
> Task :buildSrc:pluginDescriptors UP-TO-DATE
> Task :buildSrc:processResources NO-SOURCE
> Task :buildSrc:classes UP-TO-DATE
> Task :buildSrc:jar UP-TO-DATE
> Task :processResources
> Task :quarkusGenerateCode
> Task :quarkusGenerateCodeDev
> Task :compileJava UP-TO-DATE
> Task :classes
> Task :jar
========================================================================================================================
GraalVM Native Image: Generating '***-1.0.0-SNAPSHOT-runner' (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
------------------------------------------------------------------------------------------------------------------------

[1/8] Initializing...                                                                                    (0,0s @ 0,18GB)
------------------------------------------------------------------------------------------------------------------------
                        0,2s (4,1% of total time) in 10 GCs | Peak RSS: 0,55GB | CPU load: 0,76
Error: Element in class initialization configuration must end in :run_t?me, :rerun, or :bu?ld_t?me. Found: io.netty:build_time (from 'META-INF\native-image\io.netty\netty-codec-http2\native-image.properties' in 'file:///C:/Users/***/build/***-1.0.0-SNAPSHOT-native-image-source-jar/lib/io.netty.netty-codec-http2-4.1.108.Final.jar')
com.oracle.svm.core.util.UserError$UserException: Element in class initialization configuration must end in :run_t?me, :rerun, or :bu?ld_t?me. Found: io.netty:build_time (from 'META-INF\native-image\io.netty\netty-codec-http2\native-image.properties' in 'file:///C:/Users/***/build/***-1.0.0-SNAPSHOT-native-image-source-jar/lib/io.netty.netty-codec-http2-4.1.108.Final.jar')
    at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.UserError.abort(UserError.java:73)
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.lambda$processClassInitializationOptions$1(ClassInitializationFeature.java:86)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.processClassInitializationOptions(ClassInitializationFeature.java:81)
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:879)
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:590)
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:550)
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:539)
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:721)
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.start(NativeImageGeneratorRunner.java:143)
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:98)
Error: ImageSingletons do not contain key com.oracle.svm.hosted.ProgressReporterFeature
> Task :quarkusAppPartsBuild FAILED
10 actionable tasks: 6 executed, 4 up-to-date

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':quarkusAppPartsBuild'.
> There was a failure while executing work items
   > A failure occurred while executing io.quarkus.gradle.tasks.worker.BuildWorker
      > io.quarkus.builder.BuildException: Build failure: Build failed due to errors
            [error]: Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#build threw an exception: io.quarkus.deployment.pkg.steps.NativeImageBuildStep$ImageGenerationFailureException: Image generation failed. Exit code: 1
            at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.imageGenerationFailed(NativeImageBuildStep.java:471)
            at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:261)
            at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
            at java.base/java.lang.reflect.Method.invoke(Method.java:580)
            at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:849)
            at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
            at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
            at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
            at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
            at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
            at java.base/java.lang.Thread.run(Thread.java:1583)
            at org.jboss.threads.JBossThread.run(JBossThread.java:483)

* 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.

BU�LD FAILED in 15s
18:27:09: Execution finished 'build -x test -Dquarkus.package.jar.enabled=false -Dquarkus.native.enabled=true'.

The said netty native image properties file:

# Copyright 2019 The Netty Project
#
# The Netty Project licenses this file to you under the Apache License,
# version 2.0 (the "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at:
#
#   https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

Args = --initialize-at-build-time=io.netty \
       --initialize-at-run-time=io.netty.handler.codec.http2.Http2CodecUtil,io.netty.handler.codec.http2.Http2ClientUpgradeCodec,io.netty.handler.codec.http2.Http2ConnectionHandler,io.netty.handler.codec.http2.DefaultHttp2FrameWriter

I've tried changing the build arg(quarkus.native.additional-build-args) using --initialize-at-run-time with different classes and such but no chance.

Expected behavior

The quarkus project should've been built.

Actual behavior

It doesn't build, and fails.

How to Reproduce?

Output of uname -a or ver

Windows 11

Output of java -version

OpenJDK 64-Bit Server VM GraalVM CE 21.0.2+13.1 (build 21.0.2+13-jvmci-23.1-b30, mixed mode, sharing)

Mandrel or GraalVM version (if different from Java)

GraalVM CE 21.0.2+13.1

Quarkus version or git rev

3.12.0

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

Gradle 8.8

Additional information

No response

quarkus-bot[bot] commented 5 months ago

/cc @Karm (mandrel), @galderz (mandrel), @geoand (kotlin), @zakkak (mandrel,native-image)