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 when both quarkus-jdbc-postgresql and quarkus-jdbc-oracle are present #16998

Closed
j-be opened this issue May 5, 2021 · 3 comments
Labels
area/persistence OBSOLETE, DO NOT USE kind/bug Something isn't working

Comments

@j-be
Copy link
Contributor

j-be commented May 5, 2021

Introduction

I'm not necessarily complaining that Quarkus is failing. It is more the how which I think is the issue, as there there is no documentation on it, or at least it didn't catch my eye. That said, a streamlined "let me handle that for you" would be awesome, if the information is there. Not sure if it is feasible though.

Describe the bug

In your pom.xml add:

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

mvn clean package -Pnative

Expected behavior

Either of:

  • Build succeeds (perfect world scenario)
  • Build fails with a message like: "We have 2 different JDBC drivers on classpath, which causes native builds to fail. Consider using whatever you guys consider the best approach to solve this."

Actual behavior

Build fails with:

[quarkus-xxxx-1.0.0-runner:25]    classlist:   2,411.74 ms,  0.94 GB
[quarkus-xxxx-1.0.0-runner:25]        (cap):     561.60 ms,  0.94 GB
WARNING: Method java.sql.SQLXML.<init>() not found.
[quarkus-xxxx-1.0.0-runner:25]        setup:   1,956.32 ms,  0.94 GB
10:25:31,024 INFO  [org.jbo.threads] JBoss Threads version 3.2.0.Final
To see how the classes got initialized, use --trace-class-initialization=java.sql.DriverManager
[quarkus-xxxx-1.0.0-runner:25]     analysis:  18,654.34 ms,  2.65 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 the command line). 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 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

To Reproduce

I'll add a reproducer shortly.

EDIT: https://github.com/j-be/quarkus-16998

Steps to reproduce the behavior:

  1. Clone the reproducer
  2. ./mvnw clean package -DskipTests -Pnative

Configuration

Not relevant.

Output of uname -a

Linux hawk 5.4.0-72-generic #80-Ubuntu SMP Mon Apr 12 17:35:00 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04)
OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing)

GraalVM version (if different from Java)

Provided by:

[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildContainerRunner] Checking image status quay.io/quarkus/ubi-quarkus-native-image:21.0-java11
21.0-java11: Pulling from quarkus/ubi-quarkus-native-image
8f403cb21126: Pull complete 
65c0f2178ac8: Pull complete 
a1160cb39698: Pull complete 
Digest: sha256:251a0044a9827d25b8cbbb57f6eeb5a0eaf75ffa4cafe9e7b611c8d870fd9aa2
Status: Downloaded newer image for quay.io/quarkus/ubi-quarkus-native-image:21.0-java11
quay.io/quarkus/ubi-quarkus-native-image:21.0-java11

Quarkus version or git rev

1.13.3.Final

Build tool

$ ./mvnw --version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /home/juri-work/.m2/wrapper/dists/apache-maven-3.6.3-bin/1iopthnavndlasol9gbrbg6bf2/apache-maven-3.6.3
Java version: 11.0.11, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.4.0-72-generic", arch: "amd64", family: "unix"

Additional context

I could see how this would easily be fixed by having two dedicated profiles in pom.xml, but as mentioned, the error message left me staring at it like "...what?".

For the "perfect world scenario": the information which driver to use could be extracted from quarkus.datasource.db-kind in application.properties if present. I have no idea if that is even possible, or if that is just too big of an effort for this.

@j-be j-be added the kind/bug Something isn't working label May 5, 2021
@mcurcija
Copy link

mcurcija commented Jul 27, 2021

Reproducible as follows:
using quarkus 2.0.3.Final with minimal gradle deps:

dependencies {
    implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
    implementation 'io.quarkus:quarkus-jdbc-oracle'
    implementation 'io.quarkus:quarkus-jdbc-postgresql'
}

native build used: quay.io/quarkus/ubi-quarkus-native-image:21.1-java11 (FedoraCore 34 podman version 3.2.3)

fails with:

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:///project/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:///project/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)

Build is successful in both cases when oracle or postgres jdbc dependency is removed.

@Sanne Sanne added area/persistence OBSOLETE, DO NOT USE and removed triage/needs-triage labels Oct 15, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Oct 15, 2021

/cc @DavideD, @gavinking, @gsmet, @mswatosh, @yrodiere

@yrodiere
Copy link
Member

yrodiere commented Nov 2, 2021

Thanks for the report.

This issue was duplicated by #19055.

I'll close this issue, since #19055 has more discussion and links.

@yrodiere yrodiere closed this as completed Nov 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/persistence OBSOLETE, DO NOT USE kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants