Easy Fix For Quarkus 1.2.0 Native Build
If you are into Red Hat products than you have heard about promising Quarkus Java framework. It works quite well with GraalVM and has native profile sou you can run an application with no external dependencies. It is convenient if you build a container project (and who doesn't nowadays ).
The new release has just arrived and I decided to refresh my workstation to see how it works all together. I have tried to rebuild my good old demo project with the new JDK 11 and the latest framework. The native build failed with an indistinct exception.
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [error]: Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#build threw an exception: java.lang.RuntimeException: Failed to build native image at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:319) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:915) at io.quarkus.builder.BuildContext.run(BuildContext.java:279) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1426) at java.lang.Thread.run(Thread.java:748) at org.jboss.threads.JBossThread.run(JBossThread.java:479) Caused by: java.lang.RuntimeException: Image generation failed. Exit code: 1 at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:308) ... 12 more
Google didn't bring me anything but some complaints about Quarkus, GraalVM and images compatibility. But it wasn't a case (I tested 6 Graal versions), and it wasn't a memory though. Full Maven trace showed me the real cause - missing zlib headers. So the fix is quite easy, just install zlib-devel package.
[root@pvln src]# dnf install zlib-devel Last metadata expiration check: 2:37:23 ago on Sun 09 Feb 2020 07:23:47 AM EST. ........... Installed: zlib-devel-1.2.11-10.el8.x86_64 Complete! [root@pvln src]#
And have your native application ready to run.
[mmikhailidi@pvln getting-started]$ ./mvnw clean package -Pnative [INFO] Scanning for projects... ............................................. [INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] /usr/local/src/graalvm/bin/native-image -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory -J-Dvertx.disableDnsResolver=true -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=1 --initialize-at-build-time= -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy$BySpaceAndTime -jar getting-started-1.0-SNAPSHOT-runner.jar -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces -H:-AddAllCharsets -H:EnableURLProtocols=http -H:NativeLinkerOption=-no-pie -H:+JNI --no-server -H:-UseServiceLoaderFeature -H:+StackTrace getting-started-1.0-SNAPSHOT-runner [getting-started-1.0-SNAPSHOT-runner:27174] classlist: 6,134.06 ms [getting-started-1.0-SNAPSHOT-runner:27174] (cap): 1,060.04 ms [getting-started-1.0-SNAPSHOT-runner:27174] setup: 2,983.01 ms 10:01:46,481 INFO [org.jbo.threads] JBoss Threads version 3.0.0.Final [getting-started-1.0-SNAPSHOT-runner:27174] (typeflow): 15,563.74 ms [getting-started-1.0-SNAPSHOT-runner:27174] (objects): 8,731.99 ms [getting-started-1.0-SNAPSHOT-runner:27174] (features): 565.49 ms [getting-started-1.0-SNAPSHOT-runner:27174] analysis: 25,985.90 ms [getting-started-1.0-SNAPSHOT-runner:27174] (clinit): 691.94 ms [getting-started-1.0-SNAPSHOT-runner:27174] universe: 2,029.82 ms [getting-started-1.0-SNAPSHOT-runner:27174] (parse): 3,015.51 ms [getting-started-1.0-SNAPSHOT-runner:27174] (inline): 12,080.51 ms [getting-started-1.0-SNAPSHOT-runner:27174] (compile): 27,263.60 ms [getting-started-1.0-SNAPSHOT-runner:27174] compile: 44,412.33 ms [getting-started-1.0-SNAPSHOT-runner:27174] image: 2,751.31 ms [getting-started-1.0-SNAPSHOT-runner:27174] write: 729.34 ms [getting-started-1.0-SNAPSHOT-runner:27174] [total]: 85,520.01 ms [INFO] [io.quarkus.deployment.QuarkusAugmentor] Quarkus augmentation completed in 87914ms [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 01:37 min [INFO] Finished at: 2020-02-09T10:03:00-05:00 [INFO] ------------------------------------------------------------------------