quarkus
quarkus copied to clipboard
Building native executable fails.
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?
- Create a simple Quarkus Project using the generator.
- Add REST(io.quarkus:quarkus-rest) extension.
- Try to run the build native command:
build -x test -Dquarkus.package.jar.enabled=false -Dquarkus.native.enabled=true
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
/cc @Karm (mandrel), @galderz (mandrel), @geoand (kotlin), @zakkak (mandrel,native-image)
Is this still an issue with the latest versions of Quarkus?
Gradle, Windows. Gonna give it a shot with quarkus-rest...
Tested with:
- Quarkus 3.18.4
- Gradle Both 8.9 and 8.13
- Both Windows 11 and Windows 10
- Both Docker container and Local GraalVM building
Note:
- Cannot build the project with
./gradlew build -Dquarkus.package.jar.enabled=false -Dquarkus.native.enabled=trueanymore, it says 'you cannot build both native and JAR at the same time' but the auto-generated readme suggest this exact command. So i usedbuildNativecommand instead even tough it saysbuildNativecommand is deprecated.
Build
PS C:\Users\hsn\GitHub\demo> ./gradlew buildNative -D"quarkus.native.container-build"=true
> Task :buildNative
The 'buildNative' task has been deprecated in favor of 'build -Dquarkus.native.enabled=true'
jdk-21: Pulling from quarkus/ubi-quarkus-mandrel-builder-image
Digest: sha256:a0a822a9ce6f8a0788cafc993658015d8286656bd3700043fec616977692853b
Status: Image is up to date for quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-21
quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-21
========================================================================================================================
GraalVM Native Image: Generating 'demo-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,12GB)
Error: Element in class initialization configuration must end in :run_t─▒me, :rerun, or :bu─▒ld_t─▒me. Found: io.netty.util.AbstractReferenceCounted:run_time (from 'META-INF/native-image/io.netty/netty-common/native-image.properties' in 'file:///project/lib/io.netty.netty-common-4.1.118.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.util.AbstractReferenceCounted:run_time (from 'META-INF/native-image/io.netty/netty-common/native-image.properties' in 'file:///project/lib/io.netty.netty-common-4.1.118.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)
------------------------------------------------------------------------------------------------------------------------
0,3s (6,0% of total time) in 17 GCs | Peak RSS: 0,56GB | CPU load: 4,84
========================================================================================================================
Finished generating 'demo-1.0.0-SNAPSHOT-runner' in 3,3s.
> Task :quarkusAppPartsBuild FAILED
[Incubating] Problems report is available at: file:///C:/Users/hsn/GitHub/demo/build/reports/problems/problems-report.html
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:496)
at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:287)
at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:733)
at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:856)
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:2675)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654)
at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1594)
at java.base/java.lang.Thread.run(Thread.java:1583)
at org.jboss.threads.JBossThread.run(JBossThread.java:499)
* 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.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.13/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD FAILED in 21s
10 actionable tasks: 4 executed, 6 up-to-date
I finally circled back to this, on my Windows 10 VM. So far struggling to even build code-with-quakrus with Gradle :-)
for me, .\gradlew build works perfectly, even with rest extension. However, for the building native it doesn't even build with docker container which is quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-21
i feel like i need to configure something make it work, it doesn't work out of box at least i would say.
there were some problems with netty native build configurations and when i searched those bugs it looked like they've already fixed those native bugs, but it looks like there are some new bugs about it https://github.com/netty/netty/issues/14128 maybe it because of this?
@portlek
Locally Installed Mandrel 🟢
Windows native build
Using what we release as mandrel-java23-windows-amd64-24.1.2.0-Final.zip
C:\tmp\demo>powershell -c "Invoke-WebRequest -OutFile quarkus.zip -Uri 'https://code.quarkus.io/d?b=GRADLE&e=reactive-mysql-client&e=rest&e=jdbc-mariadb&e=smallrye-jwt&cn=code.quarkus.io'"
C:\tmp\demo>powershell -c "Expand-Archive -Path quarkus.zip -DestinationPath . -Force"
C:\tmp\demo>cd code-with-quarkus
set JAVA_HOME=C:\tmp\mandrel-java23-24.1.2.0-Final
set PATH=%JAVA_HOME%\bin;%PATH%
set "PATH=C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools;%PATH%"
C:\tmp\demo\code-with-quarkus> vcvars64
C:\tmp\demo\code-with-quarkus>gradlew build -Dquarkus.package.jar.enabled=false -Dquarkus.native.enabled=true
C:\tmp\demo\code-with-quarkus>build\code-with-quarkus-1.0.0-SNAPSHOT-runner.exe
See the compiler is cl.exe, microsoft:
Works just fine. The misleading README is debated over here: https://github.com/quarkusio/quarkus/issues/43661
Note in my powershell command, I selected the extensions you stated. Perhaps you have some application code?
Linux Mandrel via Podman 🟢
Linux builder image on Windows via Podman
powershell -c "Invoke-WebRequest -OutFile quarkus.zip -Uri 'https://code.quarkus.io/d?b=GRADLE&e=reactive-mysql-client&e=rest&e=jdbc-mariadb&e=smallrye-jwt&cn=code.quarkus.io'"
powershell -c "Expand-Archive -Path quarkus.zip -DestinationPath . -Force"
cd code-with-quarkus
set JAVA_HOME=C:\tmp\jdk-21.0.6+7
set PATH=%JAVA_HOME%\bin;%PATH%
gradlew build -Dquarkus.package.jar.enabled=false -Dquarkus.native.enabled=true -Dquarkus.native.container-build=true -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-23
podman build -f src/main/docker/Dockerfile.native -t my-quarkus-mandrel-app .
podman run -i --rm -p 8080:8080 my-quarkus-mandrel-app
See the compiler is gcc, redhat: windows-linux-build.txt
Note that the resulting binary is a Linux executable, so I am running it in a Linux container....
Your error log
Ad
i feel like i need to configure something make it work, it doesn't work out of box at least i would say.
and
but it looks like there are some new bugs about it https://github.com/netty/netty/issues/14128 maybe it because of this?
Given what I've shown you above, I wouldn't say this is a Gradle specific problem. Could you share a reproducer? A tiny, sanitized project that does trigger the error? It seems that merely including those extensions does not trigger it for me.
I will take the liberty of closing this generic "Building native executable fails" issue and let's open a Netty specific one provided you have the reproducer for it.
i narrowed down things you said and found out that using quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-23 image instead of quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-21, which is the default image, in fact fixed the whole problem. Thank you!