Quarkus: ORM Panache with Postgres fails on native compilation

Created on 28 May 2020  Â·  17Comments  Â·  Source: quarkusio/quarkus

Describe the bug

ORM Panache with Postgres fails on native compilation

Expected behavior

Native executable

Actual behavior

Exception is thrown.

To Reproduce
Steps to reproduce the behavior:

  1. git clone [email protected]:lordofthejars/quarkus-cockroachdb.git
  2. ./mvnw clean package -Pnative -DskipTests
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------< com.redhat.developers:cockroach-db >-----------------
[INFO] Building cockroach-db 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ cockroach-db ---
[INFO] Deleting /Users/asotobu/tmp/cockroach/cockroach-db/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ cockroach-db ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ cockroach-db ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /Users/asotobu/tmp/cockroach/cockroach-db/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ cockroach-db ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/asotobu/tmp/cockroach/cockroach-db/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ cockroach-db ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /Users/asotobu/tmp/cockroach/cockroach-db/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ cockroach-db ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ cockroach-db ---
[INFO] Building jar: /Users/asotobu/tmp/cockroach/cockroach-db/target/cockroach-db-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- quarkus-maven-plugin:1.5.0.CR1:build (default) @ cockroach-db ---
[INFO] [org.jboss.threads] JBoss Threads version 3.1.1.Final
[INFO] [org.hibernate.Version] HHH000412: Hibernate ORM core version 5.4.16.Final
[INFO] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Building native image source jar: /Users/asotobu/tmp/cockroach/cockroach-db/target/cockroach-db-1.0-SNAPSHOT-native-image-source-jar/cockroach-db-1.0-SNAPSHOT-runner.jar
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Building native image from /Users/asotobu/tmp/cockroach/cockroach-db/target/cockroach-db-1.0-SNAPSHOT-native-image-source-jar/cockroach-db-1.0-SNAPSHOT-runner.jar
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on GraalVM Version 19.3.1 CE
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] /Users/asotobu/Applications/graalvm-ce-java11-19.3.1/Contents/Home/bin/native-image -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 cockroach-db-1.0-SNAPSHOT-runner.jar -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces -H:-AddAllCharsets -H:-IncludeAllTimeZones -H:EnableURLProtocols=http,https --enable-all-security-services --no-server -H:-UseServiceLoaderFeature -H:+StackTrace cockroach-db-1.0-SNAPSHOT-runner
[cockroach-db-1.0-SNAPSHOT-runner:3138]    classlist:  11,452.61 ms
[cockroach-db-1.0-SNAPSHOT-runner:3138]        (cap):   3,006.49 ms
[cockroach-db-1.0-SNAPSHOT-runner:3138]        setup:   5,474.61 ms
08:50:00,322 INFO  [org.hib.Version] HHH000412: Hibernate ORM core version 5.4.16.Final
08:50:00,334 INFO  [org.hib.ann.com.Version] HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
08:50:00,383 INFO  [org.hib.dia.Dialect] HHH000400: Using dialect: io.quarkus.hibernate.orm.runtime.dialect.QuarkusPostgreSQL10Dialect
08:50:18,734 INFO  [org.jbo.threads] JBoss Threads version 3.1.1.Final
[cockroach-db-1.0-SNAPSHOT-runner:3138]     analysis:  45,719.66 ms
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 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 org.graalvm.collections.EconomicMapImpl.getHashIndex(EconomicMapImpl.java:414)
 parsing org.graalvm.collections.EconomicMapImpl.findHash(EconomicMapImpl.java:285)
 parsing org.graalvm.collections.EconomicMapImpl.find(EconomicMapImpl.java:254)
 parsing org.graalvm.collections.EconomicMapImpl.get(EconomicMapImpl.java:245)
 parsing com.oracle.svm.core.option.SubstrateOptionsParser.parseOption(SubstrateOptionsParser.java:201)
 parsing com.oracle.svm.core.option.RuntimeOptionParser.parseOptionAtRuntime(RuntimeOptionParser.java:186)
 parsing com.oracle.svm.core.option.RuntimeOptionParser.parse(RuntimeOptionParser.java:156)
 parsing com.oracle.svm.core.option.RuntimeOptionParser.parseAndConsumeAllOptions(RuntimeOptionParser.java:77)
 parsing com.oracle.svm.core.JavaMainWrapper.runCore(JavaMainWrapper.java:132)
 parsing com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:186)
 parsing com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_5087f5482cc9a6abc971913ece43acb471d2631b(generated:0)


 at com.oracle.graal.pointsto.util.AnalysisError.parsingError(AnalysisError.java:138)
 at com.oracle.graal.pointsto.flow.MethodTypeFlow.doParse(MethodTypeFlow.java:327)
 at com.oracle.graal.pointsto.flow.MethodTypeFlow.ensureParsed(MethodTypeFlow.java:300)
 at com.oracle.graal.pointsto.flow.MethodTypeFlow.addContext(MethodTypeFlow.java:107)
 at com.oracle.graal.pointsto.DefaultAnalysisPolicy$DefaultVirtualInvokeTypeFlow.onObservedUpdate(DefaultAnalysisPolicy.java:191)
 at com.oracle.graal.pointsto.flow.TypeFlow.notifyObservers(TypeFlow.java:343)
 at com.oracle.graal.pointsto.flow.TypeFlow.update(TypeFlow.java:385)
 at com.oracle.graal.pointsto.BigBang$2.run(BigBang.java:511)
 at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:171)
 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:177)
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:319)
 at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:185)
 at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:340)
 at com.oracle.graal.pointsto.flow.MethodTypeFlow.doParse(MethodTypeFlow.java:310)
 ... 13 more
Error: Image build request failed with exit status 1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:10 min
[INFO] Finished at: 2020-05-28T08:50:45+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.5.0.CR1:build (default) on project cockroach-db: 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:358)
[ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.base/java.lang.reflect.Method.invoke(Method.java:564)
[ERROR] at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:932)
[ERROR] at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
[ERROR] at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
[ERROR] at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
[ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
[ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
[ERROR] at java.base/java.lang.Thread.run(Thread.java:832)
[ERROR] at org.jboss.threads.JBossThread.run(JBossThread.java:479)
[ERROR] Caused by: java.lang.RuntimeException: Image generation failed. Exit code: 1
[ERROR] at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.imageGenerationFailed(NativeImageBuildStep.java:374)
[ERROR] at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:344)
[ERROR] ... 12 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.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Configuration

quarkus.http.port=8090
quarkus.swagger-ui.always-include=true

quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:26257/mydb
quarkus.datasource.db-kind=postgresql
quarkus.datasource.username=root
quarkus.datasource.password=roach1
quarkus.hibernate-orm.database.generation=update

Environment (please complete the following information):

Quarkus 1.5.0.CR1

Additional context

Also happens with ./mvnw clean package -Pnative -Dquarkus.native.container-build=true -DskipTests

kinbug triaginvalid

All 17 comments

FWIW, I followed the steps to reproduce this issue and it worked fine without any errors for me. I too used graalvm-ce-java11-19.3.1.

[cockroach-db-1.0-SNAPSHOT-runner:59587]    classlist:  12,440.60 ms
[cockroach-db-1.0-SNAPSHOT-runner:59587]        (cap):   6,190.72 ms
[cockroach-db-1.0-SNAPSHOT-runner:59587]        setup:   8,074.23 ms
13:54:22,533 INFO  [org.hib.Version] HHH000412: Hibernate ORM core version 5.4.16.Final
13:54:22,544 INFO  [org.hib.ann.com.Version] HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
13:54:22,583 INFO  [org.hib.dia.Dialect] HHH000400: Using dialect: io.quarkus.hibernate.orm.runtime.dialect.QuarkusPostgreSQL10Dialect
13:54:58,079 INFO  [org.jbo.threads] JBoss Threads version 3.1.1.Final
[cockroach-db-1.0-SNAPSHOT-runner:59587]   (typeflow): 110,850.40 ms
[cockroach-db-1.0-SNAPSHOT-runner:59587]    (objects):  75,039.81 ms
[cockroach-db-1.0-SNAPSHOT-runner:59587]   (features):   2,945.84 ms
[cockroach-db-1.0-SNAPSHOT-runner:59587]     analysis: 195,790.23 ms
[cockroach-db-1.0-SNAPSHOT-runner:59587]     (clinit):   3,022.19 ms
[cockroach-db-1.0-SNAPSHOT-runner:59587]     universe:   8,712.09 ms
[cockroach-db-1.0-SNAPSHOT-runner:59587]      (parse):  24,119.28 ms
[cockroach-db-1.0-SNAPSHOT-runner:59587]     (inline):  28,414.18 ms
[cockroach-db-1.0-SNAPSHOT-runner:59587]    (compile): 127,889.64 ms
[cockroach-db-1.0-SNAPSHOT-runner:59587]      compile: 188,434.84 ms
[cockroach-db-1.0-SNAPSHOT-runner:59587]        image:  21,854.61 ms
[cockroach-db-1.0-SNAPSHOT-runner:59587]        write:   2,619.59 ms
[cockroach-db-1.0-SNAPSHOT-runner:59587]      [total]: 505,670.53 ms

Have you tried with Docker approach?

Missatge de Jaikiran notifications@github.com del dia dj., 28 de maig
2020 a les 10:34:

FWIW, the followed the steps to reproduce this issue and it worked fine
without any errors for me. I too used graalvm-ce-java11-19.3.1.

[cockroach-db-1.0-SNAPSHOT-runner:59587] classlist: 12,440.60 ms
[cockroach-db-1.0-SNAPSHOT-runner:59587] (cap): 6,190.72 ms
[cockroach-db-1.0-SNAPSHOT-runner:59587] setup: 8,074.23 ms
13:54:22,533 INFO [org.hib.Version] HHH000412: Hibernate ORM core version 5.4.16.Final
13:54:22,544 INFO [org.hib.ann.com.Version] HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
13:54:22,583 INFO [org.hib.dia.Dialect] HHH000400: Using dialect: io.quarkus.hibernate.orm.runtime.dialect.QuarkusPostgreSQL10Dialect
13:54:58,079 INFO [org.jbo.threads] JBoss Threads version 3.1.1.Final
[cockroach-db-1.0-SNAPSHOT-runner:59587] (typeflow): 110,850.40 ms
[cockroach-db-1.0-SNAPSHOT-runner:59587] (objects): 75,039.81 ms
[cockroach-db-1.0-SNAPSHOT-runner:59587] (features): 2,945.84 ms
[cockroach-db-1.0-SNAPSHOT-runner:59587] analysis: 195,790.23 ms
[cockroach-db-1.0-SNAPSHOT-runner:59587] (clinit): 3,022.19 ms
[cockroach-db-1.0-SNAPSHOT-runner:59587] universe: 8,712.09 ms
[cockroach-db-1.0-SNAPSHOT-runner:59587] (parse): 24,119.28 ms
[cockroach-db-1.0-SNAPSHOT-runner:59587] (inline): 28,414.18 ms
[cockroach-db-1.0-SNAPSHOT-runner:59587] (compile): 127,889.64 ms
[cockroach-db-1.0-SNAPSHOT-runner:59587] compile: 188,434.84 ms
[cockroach-db-1.0-SNAPSHOT-runner:59587] image: 21,854.61 ms
[cockroach-db-1.0-SNAPSHOT-runner:59587] write: 2,619.59 ms
[cockroach-db-1.0-SNAPSHOT-runner:59587] [total]: 505,670.53 ms

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/quarkusio/quarkus/issues/9652#issuecomment-635200924,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AALSMYIY6543GE2HVW2R4SLRTYOZPANCNFSM4NM2SBRA
.

I haven't tested this in a in-container build. I probably wont' be able to since I won't have access to docker any time soon.
Does this only happen in-container?

I couldn't reproduce this either.. Tried both local GraalVM and via docker

So why this is happening to my environment? Which Java version do you have installed? In theory as I am building it inside the container this should not matter.

I am on a Mac. But again with a container, it should work.

Please append your Java and GraalVM versions to the issue. Then I can try your exact versions

openjdk 14 2020-03-17
OpenJDK Runtime Environment AdoptOpenJDK (build 14+36)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 14+36, mixed mode, sharing)

graalvm-ce-java11-19.3.1

@lordofthejars can you try using Java 11?

I can try it but, why it is failing when using the Docker approach?

You seem to be building the application with Java 14 and then using GraalVM with Java 11 to create a native image.
I don't think that is something we support, we certainly haven't tested it...

but when I do ./mvnw clean package -Pnative
-Dquarkus.native.container-build=true -DskipTests Then I am compiling
inside the container with Java11

Missatge de Georgios Andrianakis notifications@github.com del dia dj., 28
de maig 2020 a les 14:44:

You seem to be building the application with Java 14 and then using
GraalVM with Java 11 to create a native image.
I don't think that is something we support, we certainly haven't tested
it...

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/quarkusio/quarkus/issues/9652#issuecomment-635327157,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AALSMYI5BSHKG5BR5UDNEJLRTZMELANCNFSM4NM2SBRA
.

but when I do ./mvnw clean package -Pnative -Dquarkus.native.container-build=true -DskipTests Then I am compiling inside the container with Java11

That's not completely true. You are building the native-image with GraalVM Java 11, the app has still been compiled with Java 14.

Even though it is happening into the container?

Yeah, so what does mvn -version show? Whatever version of Java that shows, that is the Java version you are building with.

but when I do ./mvnw clean package -Pnative
-Dquarkus.native.container-build=true -DskipTests Then I am compiling
inside the container with Java11

As already noted by @geoand, using quarkus.native.container-build=true just means that (only) the native image generation part happens within a container. The rest of the Maven build process which involves the regular compilation etc... happens on the host machine.

Weird things happen when you use a different JDK to compile the classes vs the JDK that's underneath the one that generates the native images, e.g. https://github.com/graalvm/mandrel/issues/12.

I switched to JDK 11 and it worked. So yes this was the problem.

Was this page helpful?
0 / 5 - 0 ratings