generator-jhipster-quarkus
generator-jhipster-quarkus copied to clipboard
JHipster Quarkus can't build native image with latest version of GraalVM (21.2.0.r11-grl)
If I try to perform the steps in this demo script (which is based on this blog post) with GraalVM 21.2.0.r11-grl. It seems to work, but running the executable does not work.
sdk install java 21.2.0.r11-grl
If I downgrade to 21.0.0.2.r11-grl, it works:
sdk default java 21.0.0.2.r11-grl
To Reproduce Steps to reproduce the behavior:
sdk install java 21.2.0.r11-grl
gu install native-image
git clone https://github.com/oktadev/okta-jhipster-quarkus-example.git
cd okta-jhipster-quarkus-example
./mvnw package -Pnative -DskipTests
./target/*runner # this will fail
There is a stack trace when building, but it seems like it succeeds:
[INFO] --- quarkus-maven-plugin:1.12.1.Final:build (default) @ rocket ---
[INFO] [org.jboss.threads] JBoss Threads version 3.2.0.Final
[INFO] [org.hibernate.Version] HHH000412: Hibernate ORM core version 5.4.28.Final
[INFO] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Building native image source jar: /Users/mraible/Downloads/jhipster-quarkus/target/rocket-1.0.0-SNAPSHOT-native-image-source-jar/rocket-1.0.0-SNAPSHOT-runner.jar
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Building native image from /Users/mraible/Downloads/jhipster-quarkus/target/rocket-1.0.0-SNAPSHOT-native-image-source-jar/rocket-1.0.0-SNAPSHOT-runner.jar
[ERROR] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Unable to get GraalVM version from the native-image binary.
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] -J-DCoordinatorEnvironmentBean.transactionStatusManagerEnable=false -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize=true -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 -J-Duser.language=en -J-Duser.country=US -J-Dfile.encoding=UTF-8 --initialize-at-run-time=com.mycompany.myapp.security.RandomUtil --initialize-at-build-time= -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy\$BySpaceAndTime -H:+JNI -H:+AllowFoldMethods -jar rocket-1.0.0-SNAPSHOT-runner.jar -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces -H:-AddAllCharsets -H:EnableURLProtocols=http,https --enable-all-security-services --no-server -H:-UseServiceLoaderFeature -H:+StackTrace rocket-1.0.0-SNAPSHOT-runner
Warning: Ignoring server-mode native-image argument --no-server.
[rocket-1.0.0-SNAPSHOT-runner:16117] classlist: 4,546.27 ms, 1.69 GB
--initialize-at-build-time without arguments has been deprecated and will be removed in GraalVM 22.0.
[rocket-1.0.0-SNAPSHOT-runner:16117] (cap): 2,648.53 ms, 1.69 GB
[rocket-1.0.0-SNAPSHOT-runner:16117] setup: 4,529.07 ms, 1.69 GB
java.lang.NoClassDefFoundError: com/oracle/svm/core/jdk/LocalizationFeature
at io.quarkus.runner.AutoFeature.beforeAnalysis(AutoFeature.zig:1525)
at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$11(NativeImageGenerator.java:691)
at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:71)
at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:691)
at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:532)
at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:491)
at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:380)
at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:543)
at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:119)
at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.main(NativeImageGeneratorRunner.java:573)
Caused by: java.lang.ClassNotFoundException: com.oracle.svm.core.jdk.LocalizationFeature
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 10 more
13:17:33,132 INFO [org.hib.val.int.uti.Version] HV000001: Hibernate Validator 6.2.0.Final
13:17:41,195 INFO [org.hib.Version] HHH000412: Hibernate ORM core version 5.4.28.Final
[rocket-1.0.0-SNAPSHOT-runner:16117] (clinit): 439.50 ms, 4.47 GB
[rocket-1.0.0-SNAPSHOT-runner:16117] (typeflow): 9,570.27 ms, 4.47 GB
[rocket-1.0.0-SNAPSHOT-runner:16117] (objects): 8,955.04 ms, 4.47 GB
[rocket-1.0.0-SNAPSHOT-runner:16117] (features): 744.96 ms, 4.47 GB
[rocket-1.0.0-SNAPSHOT-runner:16117] analysis: 20,587.39 ms, 4.47 GB
[rocket-1.0.0-SNAPSHOT-runner:16117] universe: 1,389.63 ms, 4.47 GB
[rocket-1.0.0-SNAPSHOT-runner:16117] (parse): 1,058.93 ms, 4.47 GB
[rocket-1.0.0-SNAPSHOT-runner:16117] (inline): 2,709.61 ms, 5.75 GB
[rocket-1.0.0-SNAPSHOT-runner:16117] (compile): 11,848.93 ms, 5.79 GB
[rocket-1.0.0-SNAPSHOT-runner:16117] compile: 17,162.05 ms, 5.79 GB
[rocket-1.0.0-SNAPSHOT-runner:16117] image: 7,385.27 ms, 5.79 GB
[rocket-1.0.0-SNAPSHOT-runner:16117] write: 962.30 ms, 5.79 GB
[rocket-1.0.0-SNAPSHOT-runner:16117] [total]: 57,299.11 ms, 5.79 GB
# Printing build artifacts to: /Users/mraible/Downloads/jhipster-quarkus/target/rocket-1.0.0-SNAPSHOT-native-image-source-jar/rocket-1.0.0-SNAPSHOT-runner.build_artifacts.txt
[WARNING] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] objcopy executable not found in PATH. Debug symbols will not be separated from executable.
[WARNING] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] That will result in a larger native image with debug symbols embedded in it.
[INFO] [io.quarkus.deployment.QuarkusAugmentor] Quarkus augmentation completed in 63466ms
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:18 min
[INFO] Finished at: 2021-08-10T13:18:20-06:00
[INFO] ------------------------------------------------------------------------
Execution time: 1 min. 21 s.
Expected behavior
I expect that the native image would work, just like it does with 21.0.0.2.r11-grl.
Desktop (please complete the following information):
- OS: Mac
- Version Big Sur v11.4
Have you tried before upgrading GraalVM? Because we have several native builds that don't succeed atm: https://github.com/jhipster/generator-jhipster-quarkus/actions/runs/1157084906
@avdev4j Yes. If you look at my comment above, it works with the previous version.
If I downgrade to 21.0.0.2.r11-grl, it works:
I missed that. The Native builds have been very hard to fix, now we are moving to Quarkus 2, I think we should first finish this migration and then fix all the builds. I'm afraid incoming work will break them again.
this ticket makes me think we should fix all the native builds, the main branch is not stable yet since we are upgrading to Quarkus 2.
Raising bounty so I can make some money when I fix this. :)
Post upgrade, I don't see an issue with native image build/startup. Can you try latest branch code to see if this works for you as well?
With #247 changes, I tried using 22.2.r17-grl Graal VM image and didn't observe the issue. You now need to explicitly specify the quarkus profile to use for native image build like ./mvnw package -Pnative,prod -DskipTests
I was able to successfully build a native image with GraalVM CE 22.2.0 using mvn package -Pnative,prod. However, when I try to start it with target/*runner, there's an error:
'quarkus.oidc.client-id' property must be configured
If I change application.properties from:
%dev.quarkus.oidc.client-id=web_app
%dev.quarkus.oidc.credentials.secret=web_app
To:
quarkus.oidc.client-id=web_app
quarkus.oidc.credentials.secret=web_app
... it works!
However, the app doesn't start because it can't connect to MySQL and there's no Docker Compose file created for MySQL.
I created https://github.com/jhipster/generator-jhipster-quarkus/issues/251 to track the changes needed for Keycloak and MySQL to run a native image.
I probably missed to remove the dev profile scope from properties. For MySql image compose definition, you can refer to app.yml.