0

I have a small Quarkus webapp written in Java 11. It uses the hibernate-orm extension to connect to a Postgres DB and perfom basic CRUD operations. The apps runs fine on the JVM but the native-image builder in a container fails. I've tried using both the default builder-image quay.io/quarkus/ubi-quarkus-native-image:20.1.0-java11 and mandrel but the error was always the same:

mvn clean package -DskipTests -Pnative -Dquarkus.native.container-build=true -Dquarkus.container-image.build=true -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-mandrel:20.1-java11
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------< org.example:my-project-x >------------------------
[INFO] Building my-project-x 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ my-project-x ---
[INFO] Deleting /home/user-x/IdeaProjects/project-xyz/target
[INFO] 
[INFO] --- quarkus-maven-plugin:1.7.1.Final:prepare (default) @ my-project-x ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ my-project-x ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ my-project-x ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 28 source files to /home/user-x/IdeaProjects/project-xyz/target/classes
[INFO] 
[INFO] --- quarkus-maven-plugin:1.7.1.Final:prepare-tests (default) @ my-project-x ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ my-project-x ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/user-x/IdeaProjects/project-xyz/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ my-project-x ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/user-x/IdeaProjects/project-xyz/target/test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:3.0.0-M5:test (default-test) @ my-project-x ---
[INFO] Tests are skipped.
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ my-project-x ---
[INFO] Building jar: /home/user-x/IdeaProjects/project-xyz/target/my-project-x-1.0.0-SNAPSHOT.jar
[INFO] 
[INFO] --- quarkus-maven-plugin:1.7.1.Final:build (default) @ my-project-x ---
[INFO] [org.jboss.threads] JBoss Threads version 3.1.1.Final
[INFO] [org.hibernate.Version] HHH000412: Hibernate ORM core version 5.4.19.Final
[INFO] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Building native image source jar: /home/user-x/IdeaProjects/project-xyz/target/my-project-x-1.0.0-SNAPSHOT-native-image-source-jar/my-project-x-1.0.0-SNAPSHOT-runner.jar
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Building native image from /home/user-x/IdeaProjects/project-xyz/target/my-project-x-1.0.0-SNAPSHOT-native-image-source-jar/my-project-x-1.0.0-SNAPSHOT-runner.jar
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Checking image status quay.io/quarkus/ubi-quarkus-mandrel:20.1-java11
20.1-java11: Pulling from quarkus/ubi-quarkus-mandrel
57de4da701b5: Already exists 
cf0f3ebe9f53: Already exists 
cb972249a74f: Pull complete 
Digest: sha256:bc5a542165aef56c2974e9478c4a53ed5445884be0cf2044a215618cfdc8f004
Status: Downloaded newer image for quay.io/quarkus/ubi-quarkus-mandrel:20.1-java11
quay.io/quarkus/ubi-quarkus-mandrel:20.1-java11
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on GraalVM Version 20.1.0.1.Final 287bbb343e (Mandrel Distribution) (Java Version 11.0.8)
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] docker run -v /home/user-x/IdeaProjects/project-xyz/target/my-project-x-1.0.0-SNAPSHOT-native-image-source-jar:/project:z --env LANG=C --user 1001:1001 --rm quay.io/quarkus/ubi-quarkus-mandrel:20.1-java11 -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-DCoordinatorEnvironmentBean.transactionStatusManagerEnable=false -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-Dfile.encoding=UTF-8 --initialize-at-build-time= -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy\$BySpaceAndTime -H:+JNI -jar my-project-x-1.0.0-SNAPSHOT-runner.jar -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces -H:-AddAllCharsets -H:EnableURLProtocols=http,https --enable-all-security-services -H:-UseServiceLoaderFeature -H:+StackTrace my-project-x-1.0.0-SNAPSHOT-runner
[my-project-x-1.0.0-SNAPSHOT-runner:54]    classlist:   9,079.72 ms,  1.68 GB
[my-project-x-1.0.0-SNAPSHOT-runner:54]        (cap):     645.81 ms,  1.68 GB
[my-project-x-1.0.0-SNAPSHOT-runner:54]        setup:   1,980.99 ms,  1.68 GB
21:55:42,006 INFO  [org.hib.val.int.uti.Version] HV000001: Hibernate Validator 6.1.5.Final
21:55:42,139 INFO  [org.hib.Version] HHH000412: Hibernate ORM core version 5.4.19.Final
21:55:42,143 INFO  [org.hib.ann.com.Version] HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
21:55:42,168 INFO  [org.hib.dia.Dialect] HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
21:55:42,214 INFO  [org.hib.orm.beans] HHH10005002: No explicit CDI BeanManager reference was passed to Hibernate, but CDI is available on the Hibernate ClassLoader.
21:56:01,321 INFO  [org.jbo.threads] JBoss Threads version 3.1.1.Final
[my-project-x-1.0.0-SNAPSHOT-runner:54]     analysis:  39,734.17 ms,  5.07 GB
2 fatal errors detected:
Fatal error:com.oracle.graal.pointsto.util.AnalysisError$ParsingError: Error encountered while parsing com.oracle.svm.reflect.Class_getNestHost_d0409f1154f6242e625526eadd05fbcd60e7d7e9.invoke(java.lang.Object, java.lang.Object[]) 
Parsing context:
    parsing [email protected]/java.lang.reflect.Method.invoke(Method.java:566)
    parsing javax.enterprise.util.AnnotationLiteral.invoke(AnnotationLiteral.java:288)
    parsing javax.enterprise.util.AnnotationLiteral.getMemberValue(AnnotationLiteral.java:276)
    parsing javax.enterprise.util.AnnotationLiteral.hashCode(AnnotationLiteral.java:246)
    parsing app/org.graalvm.sdk/org.graalvm.collections.EconomicMapImpl.getHashIndex(EconomicMapImpl.java:414)
    parsing app/org.graalvm.sdk/org.graalvm.collections.EconomicMapImpl.findHash(EconomicMapImpl.java:285)
    parsing app/org.graalvm.sdk/org.graalvm.collections.EconomicMapImpl.find(EconomicMapImpl.java:254)
    parsing app/org.graalvm.sdk/org.graalvm.collections.EconomicMapImpl.put(EconomicMapImpl.java:426)
    parsing platform/jdk.internal.vm.compiler/org.graalvm.compiler.options.ModifiableOptionValues.update(ModifiableOptionValues.java:103)
    parsing app//com.oracle.svm.core.option.RuntimeOptionParser.parse(RuntimeOptionParser.java:174)
    parsing app//com.oracle.svm.core.option.RuntimeOptionParser.parseAndConsumeAllOptions(RuntimeOptionParser.java:77)
    parsing app//com.oracle.svm.jni.functions.JNIInvocationInterface$Exports.JNI_CreateJavaVM(JNIInvocationInterface.java:151)
    parsing com.oracle.svm.core.code.IsolateEnterStub.JNIInvocationInterface$Exports_JNI_CreateJavaVM_8df18e9ea6eb1ed7b1c899a0bbc578da0e2cc0ad(generated:0)

    at com.oracle.graal.pointsto.util.AnalysisError.parsingError(AnalysisError.java:138)
    at com.oracle.graal.pointsto.flow.MethodTypeFlow.doParse(MethodTypeFlow.java:340)
    at com.oracle.graal.pointsto.flow.MethodTypeFlow.ensureParsed(MethodTypeFlow.java:311)
    at com.oracle.graal.pointsto.flow.MethodTypeFlow.addContext(MethodTypeFlow.java:112)
    at com.oracle.graal.pointsto.DefaultAnalysisPolicy$DefaultVirtualInvokeTypeFlow.onObservedUpdate(DefaultAnalysisPolicy.java:228)
    at com.oracle.graal.pointsto.flow.TypeFlow.notifyObservers(TypeFlow.java:470)
    at com.oracle.graal.pointsto.flow.TypeFlow.update(TypeFlow.java:542)
    at com.oracle.graal.pointsto.BigBang$2.run(BigBang.java:530)
    at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:173)
    at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported method java.lang.Class.getNestHost() is reachable: The declaring class of this element has been substituted, but this element is not present in the substitution class
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The unsupported element is then reported at run time when it is accessed the first time.
    at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.lookup(AnnotationSubstitutionProcessor.java:183)
    at com.oracle.graal.pointsto.infrastructure.SubstitutionProcessor$ChainedSubstitutionProcessor.lookup(SubstitutionProcessor.java:128)
    at com.oracle.graal.pointsto.infrastructure.SubstitutionProcessor$ChainedSubstitutionProcessor.lookup(SubstitutionProcessor.java:128)
    at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookupAllowUnresolved(AnalysisUniverse.java:397)
    at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookup(AnalysisUniverse.java:377)
    at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookup(AnalysisUniverse.java:75)
    at com.oracle.graal.pointsto.infrastructure.UniverseMetaAccess.lookupJavaMethod(UniverseMetaAccess.java:93)
    at com.oracle.graal.pointsto.meta.AnalysisMetaAccess.lookupJavaMethod(AnalysisMetaAccess.java:66)
    at com.oracle.graal.pointsto.meta.AnalysisMetaAccess.lookupJavaMethod(AnalysisMetaAccess.java:39)
    at com.oracle.svm.reflect.hosted.ReflectionSubstitutionType$ReflectiveInvokeMethod.buildGraph(ReflectionSubstitutionType.java:511)
    at com.oracle.graal.pointsto.meta.AnalysisMethod.buildGraph(AnalysisMethod.java:333)
    at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:189)
    at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:352)
    at com.oracle.graal.pointsto.flow.MethodTypeFlow.doParse(MethodTypeFlow.java:322)
    ... 13 more
Fatal error:com.oracle.graal.pointsto.util.AnalysisError$ParsingError: Error encountered while parsing com.oracle.svm.reflect.Class_getNestHost_d0409f1154f6242e625526eadd05fbcd60e7d7e9.invoke(java.lang.Object, java.lang.Object[]) 
Parsing context:
    parsing [email protected]/java.lang.reflect.Method.invoke(Method.java:566)
    parsing javax.enterprise.util.AnnotationLiteral.invoke(AnnotationLiteral.java:288)
    parsing javax.enterprise.util.AnnotationLiteral.getMemberValue(AnnotationLiteral.java:276)
    parsing javax.enterprise.util.AnnotationLiteral.hashCode(AnnotationLiteral.java:246)
    parsing app/org.graalvm.sdk/org.graalvm.collections.EconomicMapImpl.getHashIndex(EconomicMapImpl.java:414)
    parsing app/org.graalvm.sdk/org.graalvm.collections.EconomicMapImpl.findHash(EconomicMapImpl.java:285)
    parsing app/org.graalvm.sdk/org.graalvm.collections.EconomicMapImpl.find(EconomicMapImpl.java:254)
    parsing app/org.graalvm.sdk/org.graalvm.collections.EconomicMapImpl.put(EconomicMapImpl.java:426)
    parsing platform/jdk.internal.vm.compiler/org.graalvm.compiler.options.ModifiableOptionValues.update(ModifiableOptionValues.java:103)
    parsing app//com.oracle.svm.core.option.RuntimeOptionParser.parse(RuntimeOptionParser.java:174)
    parsing app//com.oracle.svm.core.option.RuntimeOptionParser.parseAndConsumeAllOptions(RuntimeOptionParser.java:77)
    parsing app//com.oracle.svm.jni.functions.JNIInvocationInterface$Exports.JNI_CreateJavaVM(JNIInvocationInterface.java:151)
    parsing com.oracle.svm.core.code.IsolateEnterStub.JNIInvocationInterface$Exports_JNI_CreateJavaVM_8df18e9ea6eb1ed7b1c899a0bbc578da0e2cc0ad(generated:0)

    at com.oracle.graal.pointsto.util.AnalysisError.parsingError(AnalysisError.java:138)
    at com.oracle.graal.pointsto.flow.MethodTypeFlow.doParse(MethodTypeFlow.java:340)
    at com.oracle.graal.pointsto.flow.MethodTypeFlow.ensureParsed(MethodTypeFlow.java:311)
    at com.oracle.graal.pointsto.flow.MethodTypeFlow.addContext(MethodTypeFlow.java:112)
    at com.oracle.graal.pointsto.DefaultAnalysisPolicy$DefaultVirtualInvokeTypeFlow.onObservedUpdate(DefaultAnalysisPolicy.java:228)
    at com.oracle.graal.pointsto.flow.TypeFlow.notifyObservers(TypeFlow.java:470)
    at com.oracle.graal.pointsto.flow.TypeFlow.update(TypeFlow.java:542)
    at com.oracle.graal.pointsto.BigBang$2.run(BigBang.java:530)
    at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:173)
    at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported method java.lang.Class.getNestHost() is reachable: The declaring class of this element has been substituted, but this element is not present in the substitution class
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The unsupported element is then reported at run time when it is accessed the first time.
    at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.lookup(AnnotationSubstitutionProcessor.java:183)
    at com.oracle.graal.pointsto.infrastructure.SubstitutionProcessor$ChainedSubstitutionProcessor.lookup(SubstitutionProcessor.java:128)
    at com.oracle.graal.pointsto.infrastructure.SubstitutionProcessor$ChainedSubstitutionProcessor.lookup(SubstitutionProcessor.java:128)
    at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookupAllowUnresolved(AnalysisUniverse.java:397)
    at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookup(AnalysisUniverse.java:377)
    at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookup(AnalysisUniverse.java:75)
    at com.oracle.graal.pointsto.infrastructure.UniverseMetaAccess.lookupJavaMethod(UniverseMetaAccess.java:93)
    at com.oracle.graal.pointsto.meta.AnalysisMetaAccess.lookupJavaMethod(AnalysisMetaAccess.java:66)
    at com.oracle.graal.pointsto.meta.AnalysisMetaAccess.lookupJavaMethod(AnalysisMetaAccess.java:39)
    at com.oracle.svm.reflect.hosted.ReflectionSubstitutionType$ReflectiveInvokeMethod.buildGraph(ReflectionSubstitutionType.java:511)
    at com.oracle.graal.pointsto.meta.AnalysisMethod.buildGraph(AnalysisMethod.java:333)
    at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:189)
    at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:352)
    at com.oracle.graal.pointsto.flow.MethodTypeFlow.doParse(MethodTypeFlow.java:322)
    ... 13 more
Error: Image build request failed with exit status 1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ----------------------------

Later I decided to compile it directly with GraalVM. I downloaded graalvm-ce-java11-20.2.0, installed the native-image extension, set JAVA_HOME accordingly and it compiled without a single complaint and the native executable runs beautifully. Still I'd like to compile in a docker container without having to install GraalVM.

Enviroment:

Quarkus 1.7.1.Final

$ echo $JAVA_HOME
/opt/jdk-14/

$ java -version
openjdk version "14" 2020-03-17
OpenJDK Runtime Environment (build 14+36-1461)
OpenJDK 64-Bit Server VM (build 14+36-1461, mixed mode, sharing)

pom.xml:

<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>

Update: I've just ran the docker run command on its own and added -H:+ReportUnsupportedElementsAtRuntime, this time the error message is less vague:

Caused by: java.lang.NoClassDefFoundError: javax/security/jacc/PolicyContextException

1 Answer 1

1

Do you compile your application with Java 11 when trying to build in container?

Because it looks a lot like issues we had with applications compiled with JDK 8 and then build with a GraalVM/Mandrel Java 11 container.

Sign up to request clarification or add additional context in comments.

4 Comments

I'm using Open JDK 14 (build 14+36-1461) to build and source and target are set to 11 in pom.xml.
I've updated the question after adding H:+ReportUnsupportedElementsAtRuntime to docker run.
Can you try building with JDK 11 and see how it goes?
You were right, with JDK 11 (build 11+28) it works - I can build using both ubi-quarkus-native-image:20.1.0-java11 and quay.io/quarkus/ubi-quarkus-mandrel:20.1-java11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.