Building native image in windows with quarkus

“mvn package -Pnative” builds the native image from quarkus project. Important step is we have to run that mvn command from “native tools commnad” of visual studio. If you run the command from regular command prompt you get the error below [INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildRunner] C:\Program Files\GraalVM\graalvm-ce-java17-21.3.0\bin\native-image.cmd -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dsun.nio.ch.maxUpdateArraySize=100 -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=3 -J-Duser.language=en -J-Duser.country=US -J-Dfile.encoding=UTF-8 -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy\$BySpaceAndTime -H:+JNI -H:+AllowFoldMethods -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces -H:-AddAllCharsets -H:EnableURLProtocols=http -H:-UseServiceLoaderFeature -H:+StackTrace chinese-lang-1.0.0-SNAPSHOT-runner -jar chinese-lang-1.0.0-SNAPSHOT-runner.jar [chinese-lang-1.0.0-SNAPSHOT-runner:6432] classlist: 5,366.54 ms, 0.96 GB [chinese-lang-1.0.0-SNAPSHOT-runner:6432] setup: 943.11 ms, 0.96 GB Error: Default native-compiler executable 'cl.exe' not found via environment variable PATH Error: To prevent native-toolchain checking provide command-line option -H:-CheckToolchain com.oracle.svm.core.util.UserError$UserException: Default native-compiler executable 'cl.exe' not found via environment variable PATH To prevent native-toolchain checking provide command-line option -H:-CheckToolchain at com.oracle.svm.core.util.UserError.abort(UserError.java:144) at com.oracle.svm.hosted.c.codegen.CCompilerInvoker.addSkipCheckingInfo(CCompilerInvoker.java:104) at com.oracle.svm.hosted.c.codegen.CCompilerInvoker.<init>(CCompilerInvoker.java:72) at com.oracle.svm.hosted.c.codegen.CCompilerInvoker$WindowsCCompilerInvoker.<init>(CCompilerInvoker.java:110) at com.oracle.svm.hosted.c.codegen.CCompilerInvoker.create(CCompilerInvoker.java:84) at com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:864) at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:527) at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:488) at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:403) at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:569) at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:122) at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.main(NativeImageGeneratorRunner.java:599) [chinese-lang-1.0.0-SNAPSHOT-runner:6432] [total]: 6,384.40 ms, 0.96 GB # Printing build artifacts to: C:\Users\ozkan\projects\chinese-lang\target\chinese-lang-1.0.0-SNAPSHOT-native-image-source-jar\chinese-lang-1.0.0-SNAPSHOT-runner.build_artifacts.txt Error: Image build request failed with exit status 1 [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 22.552 s [INFO] Finished at: 2021-11-03T21:07:37Z [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:2.4.1.Final:build (default) on project chinese-lang: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [ERROR] [error]: Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#build threw an exception: java.lang.RuntimeException: Failed to build native image [ERROR] at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:233) [ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) [ERROR] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [ERROR] at java.base/java.lang.reflect.Method.invoke(Method.java:568) [ERROR] at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:821) [ERROR] at io.quarkus.builder.BuildContext.run(BuildContext.java:277) [ERROR] at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478) [ERROR] at java.base/java.lang.Thread.run(Thread.java:833) [ERROR] at org.jboss.threads.JBossThread.run(JBossThread.java:501) [ERROR] Caused by: java.lang.RuntimeException: Image generation failed. Exit code: 1 [ERROR] at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.imageGenerationFailed(NativeImageBuildStep.java:369) [ERROR] at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:213) [ERROR] ... 11 more [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. If you run the command from native tools result is below ...

November 3, 2021 · 4 min · Özkan Pakdil

Could not find MessageBodyWriter for response object of type: io.vertx.reactivex.core.buffer.Buffer of media type: text/html;charset=UTF-8

I was trying to use freemarker with quarkus and vertx. I start getting this error Could not find MessageBodyWriter for response object of type: io.vertx.reactivex.core.buffer.Buffer of media type: text/html;charset=UTF-8 And code look like below. I was trying to use reactive approach. @GET @Produces(MediaType.TEXT_HTML) public Uni<Object> doSomethingAsync() throws Exception { io.vertx.core.Vertx params = vertx.getDelegate(); io.vertx.reactivex.core.Vertx args = new io.vertx.reactivex.core.Vertx(params); FreeMarkerTemplateEngine engine = FreeMarkerTemplateEngine.create(args); List<ExampleObject> exs = new ArrayList<>(); for (int i = 0; i < 10; i++) { exs.add(new ExampleObject("name:" + i, "dev:" + i)); } HashMap data = new HashMap<>(); data.put("title", "Vert.x Web"); data.put("exampleObject", new ExampleObject("name", "dev")); data.put("systems", exs); Single<Buffer> rxRender = engine.rxRender(data, "/templates/index.htm"); Buffer page = null; try { page = rxRender.toFuture().get(); } catch (Exception ex) { ex.printStackTrace(); // e.printStacktrace(); } return Uni.createFrom().item(page); } I check and could not find a proper solution here is how I solved it. ...

June 2, 2020 · 1 min · Özkan Pakdil