Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native build fails with postgres and oracle drivers together #19055

Closed
vsevel opened this issue Jul 28, 2021 · 8 comments · Fixed by #22255
Closed

Native build fails with postgres and oracle drivers together #19055

vsevel opened this issue Jul 28, 2021 · 8 comments · Fixed by #22255
Labels
area/native-image area/persistence OBSOLETE, DO NOT USE kind/bug Something isn't working
Milestone

Comments

@vsevel
Copy link
Contributor

vsevel commented Jul 28, 2021

Describe the bug

I have added the following dependencies :

		<dependency>
			<groupId>io.quarkus</groupId>
			<artifactId>quarkus-jdbc-oracle</artifactId>
		</dependency>
		<dependency>
			<groupId>io.quarkus</groupId>
			<artifactId>quarkus-jdbc-postgresql</artifactId>
		</dependency>

The native build fails.

It works with postgres alone, or oracle alone, but not with both together.

It means I cannot build an application, which may target postgres and/or oracle.

Expected behavior

Able to build the native image with both drivers postgres and oracle in the same executable.

Actual behavior

The build fails with:

[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on GraalVM 21.1.0 Java 11 CE (Java Version 11.0.11+8-jvmci-21.1-b05)
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildRunner] /home/sevel/graalvm-ce-java11-21.1.0/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=3 -J-Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize=true -J-Duser.language=en -J-Duser.country=US -J-Dfile.encoding=UTF-8 --allow-incomplete-classpath -J-Djava.io.tmpdir=/home/sevel/tmpdir -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy\$BySpaceAndTime -H:+JNI -H:+AllowFoldMethods -jar OrderProposal-2.0.0-SNAPSHOT-runner.jar -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces -J-Xmx10g -H:-AddAllCharsets -H:EnableURLProtocols=http,https -H:-UseServiceLoaderFeature -H:+StackTrace OrderProposal-2.0.0-SNAPSHOT-runner
[OrderProposal-2.0.0-SNAPSHOT-runner:4115]    classlist:   8,410.22 ms,  1.50 GB
[OrderProposal-2.0.0-SNAPSHOT-runner:4115]        (cap):     758.97 ms,  1.50 GB
WARNING: Method java.sql.SQLXML.<init>() not found.
[OrderProposal-2.0.0-SNAPSHOT-runner:4115]        setup:   3,522.08 ms,  1.50 GB
11:21:57,485 INFO  [org.hib.val.int.uti.Version] HV000001: Hibernate Validator 6.2.0.Final
11:21:57,598 INFO  [org.hib.Version] HHH000412: Hibernate ORM core version 5.5.4.Final
11:21:57,606 INFO  [org.hib.ann.com.Version] HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
11:21:57,649 INFO  [org.hib.dia.Dialect] HHH000400: Using dialect: org.hibernate.dialect.Oracle12cDialect
11:21:58,162 INFO  [org.jbo.res.res.i18n] RESTEASY002225: Deploying javax.ws.rs.core.Application: class com.lodh.gestion.orderproposal.infrastructure.JaxRsActivator
To see how the classes got initialized, use --trace-class-initialization=java.sql.DriverManager
[OrderProposal-2.0.0-SNAPSHOT-runner:4115]     analysis:  20,235.47 ms,  2.74 GB
Error: Classes that should be initialized at run time got initialized during image building:
 java.sql.DriverManager the class was requested to be initialized at run time (from jar:file:///export/soft/appl/quarkus-order-proposal/OrderProposal/target/OrderProposal-2.0.0-SNAPSHOT-native-image-source-jar/lib/com.oracle.database.jdbc.ojdbc8-21.1.0.0.jar!/META-INF/native-image/native-image.properties). To see why java.sql.DriverManager got initialized use --trace-class-initialization=java.sql.DriverManager

com.oracle.svm.core.util.UserError$UserException: Classes that should be initialized at run time got initialized during image building:
 java.sql.DriverManager the class was requested to be initialized at run time (from jar:file:///export/soft/appl/quarkus-order-proposal/OrderProposal/target/OrderProposal-2.0.0-SNAPSHOT-native-image-source-jar/lib/com.oracle.database.jdbc.ojdbc8-21.1.0.0.jar!/META-INF/native-image/native-image.properties). To see why java.sql.DriverManager got initialized use --trace-class-initialization=java.sql.DriverManager

        at com.oracle.svm.core.util.UserError.abort(UserError.java:68)
        at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.checkDelayedInitialization(ConfigurableClassInitialization.java:545)
        at com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.duringAnalysis(ClassInitializationFeature.java:228)
        at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$14(NativeImageGenerator.java:765)
        at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:71)
        at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:765)
        at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:582)
        at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$2(NativeImageGenerator.java:495)
        at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
        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)
Error: Image build request failed with exit status 1

How to Reproduce?

Add both dependencies on an application, and build a native image.

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

GraalVM 21.1.0 Java 11 CE (Java Version 11.0.11+8-jvmci-21.1-b05)

Quarkus version or git rev

2.1.0

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

@vsevel vsevel added the kind/bug Something isn't working label Jul 28, 2021
@Sanne
Copy link
Member

Sanne commented Jul 28, 2021

This is caused by the GraalVM directives included in the Oracle JDBC driver.

I did report such issues to the Oracle team, they agreed to fix it but unfortunately also mentioned it's going to take some time to see a new release.

I assume you are an Oracle customer? I would suggest to report it to them, they should be able to give you a patched driver much faster than the ones they release in Maven.

I can also try to craft a workaround from our side for this specific error - but I'm not sure that's possible, and even if we do I suspect it will be followed by other similar problems, as the metadata in their driver sets various flags "globally" (which shouldn't be modified globally).

@vsevel
Copy link
Contributor Author

vsevel commented Jul 28, 2021

hi @Sanne no hurry for me. And we have started running tests with oracle xe instead of postgres.
I just wanted to create the issue if this was not known already.

@inforefiner
Copy link

inforefiner commented Oct 25, 2021

Hi @Sanne, I encounted the same issue, and I tried degrade oracle driver to 19, which has no native-image.properties included, but still not work. Do you have any workaround for this issue? Thanks

@kvandenhoute
Copy link

kvandenhoute commented Dec 2, 2021

Hi @Sanne, are there any updates on this issue? I'm struggling with this as well (on 1.13.7-Final). Thank you

@Sanne
Copy link
Member

Sanne commented Dec 3, 2021

I got distracted by other things, sorry. Back on this now.

Related: #21069

@inforefiner sorry downgrading the Oracle driver isn't going to work: the new version contains lots of useful metadat afor GraalVM, only a couple little details need fixing - but we still need all the others.

but out of cursiosity, did you get the same error? Or what error precisely? If you happen to have stack traces please paste them here, it's might be useful to know the details even if I suspect that's a dead end (I might be wrong..)

@kvandenhoute you really should upgrade - many other related improvements have made it in Quarkus which are more recent than 1.13. However, similarly if you have a specific stack trace please paste them - always useful to have a reference here.

@kvandenhoute
Copy link

kvandenhoute commented Dec 3, 2021

Hi @Sanne , no problem. Thanks for your response.
Plan is to ugrade to latest Quarkus, but we're trying to do it step by step. First to 1.13.7 then to latest 2.x.x. I'll keep an eye on this and the related issue.

Stacktrace for reference (this project includes postgresql, mssql and oracle):

[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on GraalVM Version 21.0.0 (Java Version 11.0.10+8-jvmci-21.0-b06)
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildRunner] /opt/graalvm/bin/native-image -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-DCoordinatorEnvironmentBean.transactionStatusManagerEnable=false -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 -J-Duser.language=en -J-Duser.country=US -J-Dfile.encoding=UTF-8 --allow-incomplete-classpath -H:IncludeResourceBundles=oracle.net.jdbc.nl.mesg.NLSR,oracle.net.mesg.Message --initialize-at-build-time= -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy\$BySpaceAndTime -H:+JNI -H:+AllowFoldMethods -jar test-runner.jar -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces -H:+AddAllCharsets -H:EnableURLProtocols=http,https --enable-all-security-services -H:NativeLinkerOption=-no-pie --no-server -H:-UseServiceLoaderFeature -H:+StackTrace test-runner
[test-runner:468]    classlist:  13,056.53 ms,  1.68 GB
[test-runner:468]        (cap):   1,164.32 ms,  1.68 GB
WARNING: Method java.sql.SQLXML.<init>() not found.
[test-runner:468]        setup:   5,188.50 ms,  1.68 GB
12:13:59,140 INFO  [org.hib.val.int.uti.Version] HV000001: Hibernate Validator 6.2.0.Final
12:13:59,819 INFO  [org.hib.Version] HHH000412: Hibernate ORM core version 5.4.29.Final
12:13:59,854 INFO  [org.hib.ann.com.Version] HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
12:14:00,079 INFO  [org.hib.dia.Dialect] HHH000400: Using dialect: xx.hibernate.dialects.F_SQLServerDialect
12:14:00,334 INFO  [org.hib.dia.Dialect] HHH000400: Using dialect: xx.hibernate.dialects.F_OracleDialect
12:14:00,423 WARN  [org.hib.eng.jdb.con.int.ConnectionProviderInitiator] HHH000181: No appropriate connection provider encountered, assuming application will be supplying connections
12:14:00,425 INFO  [org.hib.dia.Dialect] HHH000400: Using dialect: xx.hibernate.dialects.F_PostgreSQLDialect
To see how the classes got initialized, use --trace-class-initialization=java.sql.DriverManager
[test-runner:468]     analysis:  34,563.80 ms, Error: Classes that should be initialized at run time got initialized during image building:
 java.sql.DriverManager the class was requested to be initialized at run time (from the command line). To see why java.sql.DriverManager got initialized use --trace-class-initialization=java.sql.DriverManager

 2.70 GB
com.oracle.svm.core.util.UserError$UserException: Classes that should be initialized at run time got initialized during image building:
 java.sql.DriverManager the class was requested to be initialized at run time (from the command line). To see why java.sql.DriverManager got initialized use --trace-class-initialization=java.sql.DriverManager

	at com.oracle.svm.core.util.UserError.abort(UserError.java:68)
	at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.checkDelayedInitialization(ConfigurableClassInitialization.java:539)
	at com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.duringAnalysis(ClassInitializationFeature.java:226)
	at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$8(NativeImageGenerator.java:740)
	at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:70)
	at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:740)
	at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:563)
	at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:476)
	at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
	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)
Error: Image build request failed with exit status 1

@Sanne
Copy link
Member

Sanne commented Dec 15, 2021

Fixed it :)

@gsmet gsmet modified the milestones: 2.7 - main, 2.5.4.Final Dec 17, 2021
gsmet pushed a commit to gsmet/quarkus that referenced this issue Dec 17, 2021
@inforefiner
Copy link

Thanks @Sanne! I'll give it try right now.

gsmet pushed a commit to gsmet/quarkus that referenced this issue Dec 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/native-image area/persistence OBSOLETE, DO NOT USE kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants