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

Oracle JDBC extension in native mode doesn´t work with XA #23341

Closed
bvahdat opened this issue Feb 1, 2022 · 11 comments · Fixed by #40704
Closed

Oracle JDBC extension in native mode doesn´t work with XA #23341

bvahdat opened this issue Feb 1, 2022 · 11 comments · Fixed by #40704
Labels
area/persistence OBSOLETE, DO NOT USE env/windows Impacts Windows machines kind/bug Something isn't working
Milestone

Comments

@bvahdat
Copy link

bvahdat commented Feb 1, 2022

Describe the bug

Using the provided reproducer below with enabled XA on this line I get the following error when accessing http://localhost:8080/hello:

2022-02-01 14:00:05,072 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-0) HTTP Request to /hello failed, error id: 52892a3f-33b3-4973-81ca-04bca84e9cb3-1: org.jboss.resteasy.spi.UnhandledException: java.sql.SQLException: Invalid Oracle URL specified: OracleDataSource.makeURL
        at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:105)
        at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:359)
        at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:218)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:519)
        at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:261)
        at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161)
        at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
        at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:164)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:247)
        at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
        at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:151)
        at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$1.run(VertxRequestHandler.java:91)
        at io.quarkus.vertx.core.runtime.VertxCoreRecorder$13.runWith(VertxCoreRecorder.java:543)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.lang.Thread.run(Thread.java:833)
        at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:596)
        at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
Caused by: java.sql.SQLException: Invalid Oracle URL specified: OracleDataSource.makeURL
        at oracle.jdbc.datasource.impl.OracleDataSource.makeURL(OracleDataSource.java:1294)
        at oracle.jdbc.datasource.impl.OracleDataSource.getURL(OracleDataSource.java:1066)
        at oracle.jdbc.xa.client.OracleXADataSource.getPooledConnection(OracleXADataSource.java:362)
        at oracle.jdbc.xa.client.OracleXADataSource.getXAConnection(OracleXADataSource.java:233)
        at oracle.jdbc.xa.client.OracleXADataSource.getXAConnectionInternal(OracleXADataSource.java:281)
        at oracle.jdbc.xa.client.OracleXADataSource.getXAConnection(OracleXADataSource.java:174)
        at oracle.jdbc.xa.client.OracleXADataSource.getXAConnection(OracleXADataSource.java:146)
        at io.agroal.pool.ConnectionFactory.createConnection(ConnectionFactory.java:216)
        at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:513)
        at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:494)
        at java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at io.agroal.pool.util.PriorityScheduledExecutor.beforeExecute(PriorityScheduledExecutor.java:75)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        ... 3 more

And without XA (although -H:+AddAllCharsets per default is set):

2022-02-01 14:04:49,659 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-0) HTTP Request to /hello failed, error id: 4bfa0e07-3ae3-4f3a-9064-03004804f9bc-1: org.jboss.resteasy.spi.UnhandledException: java.lang.IllegalStateException: Missing character set id 46 is not loaded at image build time
        at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:105)
        at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:359)
        at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:218)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:519)
        at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:261)
        at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161)
        at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
        at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:164)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:247)
        at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
        at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:151)
        at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$1.run(VertxRequestHandler.java:91)
        at io.quarkus.vertx.core.runtime.VertxCoreRecorder$13.runWith(VertxCoreRecorder.java:543)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.lang.Thread.run(Thread.java:833)
        at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:596)
        at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
Caused by: java.lang.IllegalStateException: Missing character set id 46 is not loaded at image build time
        at oracle.sql.CharacterSet.make(CharacterSet.java:122)
        at oracle.jdbc.driver.DBConversion.init(DBConversion.java:184)
        at oracle.jdbc.driver.DBConversion.<init>(DBConversion.java:137)
        at oracle.jdbc.driver.T4CConnection.doCharSetNegotiation(T4CConnection.java:2620)
        at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:2184)
        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:652)
        at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:1086)
        at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:90)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:728)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:649)
        at io.agroal.pool.ConnectionFactory.createConnection(ConnectionFactory.java:210)
        at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:513)
        at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:494)
        at java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at io.agroal.pool.util.PriorityScheduledExecutor.beforeExecute(PriorityScheduledExecutor.java:75)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        ... 3 more

Expected behavior

I expect this extension to work properly the same way as in JVM mode.

Actual behavior

It fails in native mode both w/o XA.

How to Reproduce?

Output of uname -a or ver

Linux XYZ 4.4.0-18362-Microsoft #1801-Microsoft Sat Sep 11 15:28:00 PST 2021 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version "17.0.1" 2021-10-19 OpenJDK Runtime Environment GraalVM CE 21.3.0 (build 17.0.1+12-jvmci-21.3-b05) OpenJDK 64-Bit Server VM GraalVM CE 21.3.0 (build 17.0.1+12-jvmci-21.3-b05, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.6.3.Final (Also tried out 999-SNAPSHOT)

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

Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537) Maven home: C:\Develop\apache-maven-3.8.4 Java version: 17.0.1, vendor: GraalVM Community, runtime: C:\Develop\graalvm-17 Default locale: en_US, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Additional information

No response

@quarkus-bot
Copy link

quarkus-bot bot commented Feb 2, 2022

/cc @Sanne, @barreiro, @yrodiere

@gastaldi gastaldi added area/persistence OBSOLETE, DO NOT USE and removed area/agroal labels Feb 2, 2022
@yrodiere
Copy link
Member

yrodiere commented Feb 17, 2022

@Sanne is this part of the problems you're already trying to address in the Oracle JDBC driver? Or should I have a look?

@Sanne
Copy link
Member

Sanne commented Feb 22, 2022

I haven't looked at this issue @yrodiere - if you want to feel free to take it.

FYI it smells like two different issues? the "Missing character set id 46" smells like related to a618020

@ghost
Copy link

ghost commented Mar 14, 2022

Hi everyone,

I think I was able to fix it locally: https://github.com/bvahdat/code-with-quarkus3/pull/1/files

My env is the following:

alex@wsl2:~/proj/github.com/bvahdat/code-with-quarkus3$ uname -a
Linux wsl2 5.10.16.3-microsoft-standard-WSL2 #1 SMP Fri Apr 2 22:23:49 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
alex@wsl2:~/proj/github.com/bvahdat/code-with-quarkus3$ java -version
openjdk version "11.0.14" 2022-01-18
OpenJDK Runtime Environment Temurin-11.0.14+9 (build 11.0.14+9)
OpenJDK 64-Bit Server VM Temurin-11.0.14+9 (build 11.0.14+9, mixed mode)
alex@wsl2:~/proj/github.com/bvahdat/code-with-quarkus3$ mvn --version
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: /home/alex/.sdkman/candidates/maven/current
Java version: 11.0.14, vendor: Eclipse Adoptium, runtime: /home/alex/.sdkman/candidates/java/22.0.0.2.r11-mandrel
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "5.10.16.3-microsoft-standard-wsl2", arch: "amd64", family: "unix"
alex@wsl2:~/proj/github.com/bvahdat/code-with-quarkus3$ native-image --version
native-image 22.0.0.2-Final Mandrel Distribution (Java Version 11.0.14+9)

If you could confirm that the fix is also working in your env (locally or in a CI/CD pipeline), that would be really awesome.

The reflection config could then probably be added to the corresponding quarkus extension (quarkus-jdbc-oracle).

P.S.

  • When I called curl http://127.0.0.1:8080/hello I got and empty object ({}) as a response. However, I didn't get any exception in the native application (both with and without XA setting). So that should be fine I guess.
  • I've used a containerized Oracle Express Edition (gvenzl/oracle-xe:21.3.0-slim) for testing the fix: https://github.com/gvenzl/oci-oracle-xe

@gsmet
Copy link
Member

gsmet commented Mar 14, 2022

@Sanne ^

@Sanne
Copy link
Member

Sanne commented Apr 13, 2022

@progaddict sorry I missed this - crazy busy times :)

Sounds promising, I'll have a look

@turing85
Copy link
Contributor

Any progress on this one?

@david-deck-gca
Copy link

Hello. I am an architect with Group Charles André.

We are facing that same issue except that we use PostreSQL instead of DB2.

In the logs, I've found the "Invalid Oracle URL specified: OracleDataSource.makeURL" error and two warnings :
2024-05-12 08:41:53,623 d378af8b4ee5 [51] WARN [io.agr.pool] (agroal-21) Datasource '': Ignoring property 'password': No setter in class oracle.jdbc.xa.client.OracleXADataSource
2024-05-12 08:41:53,623 d378af8b4ee5 [51] WARN [io.agr.pool] (agroal-21) Datasource '': Ignoring property 'user': No setter in class oracle.jdbc.xa.client.OracleXADataSource
2024-05-12 08:41:53,627 d378af8b4ee5 [51] WARN [io.agr.pool] (agroal-21) Datasource '': ORA-17067: Invalid Oracle URL specified: OracleDataSource.makeURL

I think that GraalVM native-image removes all methods from oracle.jdbc.datasource.impl.OracleDataSource and oracle.jdbc.xa.OracleXADataSource classes so I've put them back using the @RegisterForReflection annotation and now everything seems to work :

@RegisterForReflection(targets={
    oracle.jdbc.datasource.impl.OracleDataSource.class,
    oracle.jdbc.xa.OracleXADataSource.class
})
public class MyReflectionConfiguration {
}

I kind of understand it's the Oracle JDBC Driver itself that has to be fixed but I do hope the Quarkus Team will find a Workdaround because we try to avoid deploying our apps with JVMs and most of our databases are Oracle ones.

In the meantime, could someone tell me if my "@RegisterForReflection" solution can be used in production ?

Regards

@gsmet
Copy link
Member

gsmet commented May 12, 2024

Yes you can use your workaround. I think we already register the XA data source class when using XA but we might need to be more clever. I will have a look on Monday.

@gsmet gsmet changed the title Oracle JDBC extension in native mode doesn´t work w/o XA Oracle JDBC extension in native mode doesn´t work wigh XA May 17, 2024
@gsmet gsmet changed the title Oracle JDBC extension in native mode doesn´t work wigh XA Oracle JDBC extension in native mode doesn´t work with XA May 17, 2024
gsmet added a commit to gsmet/quarkus that referenced this issue May 17, 2024
We need to register a few more classes for reflection and also all their
nested classes, which is why I use `@RegisterForReflection` instead of
the usual build item.

Fixes quarkusio#23341
@gsmet
Copy link
Member

gsmet commented May 17, 2024

I was able to reproduce the issue and included the fix you put in place in the extension so once the fix got released, you won't need to do it yourself manually.

See #40704 .

@gsmet
Copy link
Member

gsmet commented May 17, 2024

@david-deck-gca Thanks for reviving this issue and providing your insights :)

gsmet added a commit to gsmet/quarkus that referenced this issue May 21, 2024
We need to register a few more classes for reflection and also all their
nested classes, which is why I use `@RegisterForReflection` instead of
the usual build item.

Fixes quarkusio#23341
@quarkus-bot quarkus-bot bot added this to the 3.12 - main milestone May 22, 2024
@gsmet gsmet modified the milestones: 3.12 - main, 3.8.5 May 22, 2024
gsmet added a commit to gsmet/quarkus that referenced this issue May 22, 2024
We need to register a few more classes for reflection and also all their
nested classes, which is why I use `@RegisterForReflection` instead of
the usual build item.

Fixes quarkusio#23341

(cherry picked from commit f69176f)
gsmet added a commit to gsmet/quarkus that referenced this issue May 22, 2024
We need to register a few more classes for reflection and also all their
nested classes, which is why I use `@RegisterForReflection` instead of
the usual build item.

Fixes quarkusio#23341

(cherry picked from commit f69176f)
gsmet added a commit to gsmet/quarkus that referenced this issue May 23, 2024
We need to register a few more classes for reflection and also all their
nested classes, which is why I use `@RegisterForReflection` instead of
the usual build item.

Fixes quarkusio#23341

(cherry picked from commit f69176f)
gsmet added a commit to gsmet/quarkus that referenced this issue May 23, 2024
We need to register a few more classes for reflection and also all their
nested classes, which is why I use `@RegisterForReflection` instead of
the usual build item.

Fixes quarkusio#23341

(cherry picked from commit f69176f)
gsmet added a commit to gsmet/quarkus that referenced this issue Jun 4, 2024
We need to register a few more classes for reflection and also all their
nested classes, which is why I use `@RegisterForReflection` instead of
the usual build item.

Fixes quarkusio#23341

(cherry picked from commit f69176f)
gsmet added a commit to gsmet/quarkus that referenced this issue Jun 4, 2024
We need to register a few more classes for reflection and also all their
nested classes, which is why I use `@RegisterForReflection` instead of
the usual build item.

Fixes quarkusio#23341

(cherry picked from commit f69176f)
gsmet added a commit to gsmet/quarkus that referenced this issue Jun 4, 2024
We need to register a few more classes for reflection and also all their
nested classes, which is why I use `@RegisterForReflection` instead of
the usual build item.

Fixes quarkusio#23341

(cherry picked from commit f69176f)
holly-cummins pushed a commit to holly-cummins/quarkus that referenced this issue Jul 31, 2024
We need to register a few more classes for reflection and also all their
nested classes, which is why I use `@RegisterForReflection` instead of
the usual build item.

Fixes quarkusio#23341
danielsoro pushed a commit to danielsoro/quarkus that referenced this issue Sep 20, 2024
We need to register a few more classes for reflection and also all their
nested classes, which is why I use `@RegisterForReflection` instead of
the usual build item.

Fixes quarkusio#23341
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 env/windows Impacts Windows machines kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants