Closed bvahdat closed 2 weeks ago
/cc @mswatosh
When you're enabling XA, is it failing in native only or both in native and JVM?
Thanks @gsmet for your support and sorry for not mentioning that point already. It fails with the same error as mentioned above both in the native and JVM modes. The error message in native mode though reads a bit different:
Caused by: com.ibm.db2.jcc.am.SqlException: [jcc]Missing resource bundle: A resource bundle could not be found in the com.ibm.db2.jcc package for IBM Data Server Driver for JDBC and SQLJ ERRORCODE=-4472, SQLSTATE=null
But as you see with the same values: ERRORCODE=-4472, SQLSTATE=null
The resource bundle issue will be a different issue that is native specific.
@barreiro could you enlighten us on how Agroal is supposed to work with DB2 + XA? I'm not sure to understand why it tries to inject the URL in it.
I'm not sure to understand why it tries to inject the URL in it.
Because the Quarkus application has following in application.properties I think:
%prod.quarkus.datasource.P82DataSource.jdbc.url=${P82_URL}
but DB2 XADataSource class doesn't have such setter, consequently you'll see those warns above by Agroal.
So we also tried both
%prod.quarkus.datasource.P82DataSource.serverName=<IP_ADDRESS>
%prod.quarkus.datasource.P82DataSource.portNumber=446
%prod.quarkus.datasource.P82DataSource.databaseName=<DATABASE_NAME>
and
%prod.quarkus.datasource.P82DataSource.jdbc.serverName=<IP_ADDRESS>
%prod.quarkus.datasource.P82DataSource.jdbc.portNumber=446
%prod.quarkus.datasource.P82DataSource.jdbc.databaseName=<DATABASE_NAME>
but this time Quarkus itself warns that it's ignoring them because it doesn't know them. It doesn't pass them to Agroal :(
@yasserzamani you'll have to use quarkus.datasource.jdbc.additional-jdbc-properties
to inject those settings.
That will be:
%prod.quarkus.datasource.P82DataSource.jdbc.additional-jdbc-properties.serverName=<IP_ADDRESS>
%prod.quarkus.datasource.P82DataSource.jdbc.additional-jdbc-properties.portNumber=446
%prod.quarkus.datasource.P82DataSource.jdbc.additional-jdbc-properties.databaseName=<DATABASE_NAME>
Thanks a lot @barreiro yes it worked
@barreiro should we document it?
@yasserzamani you'll have to use
quarkus.datasource.jdbc.additional-jdbc-properties
to inject those settings.That will be:
%prod.quarkus.datasource.P82DataSource.jdbc.additional-jdbc-properties.serverName=<IP_ADDRESS> %prod.quarkus.datasource.P82DataSource.jdbc.additional-jdbc-properties.portNumber=446 %prod.quarkus.datasource.P82DataSource.jdbc.additional-jdbc-properties.databaseName=<DATABASE_NAME>
Additionaly we had to set the driver type as well to make it work:
%prod.quarkus.datasource.P82DataSource.jdbc.additional-jdbc-properties.driverType=4
And I think the other issue is still the resource bundle problem to make it work natively as well. I used GraalVM agent to find out what else is still missing:
https://www.graalvm.org/reference-manual/native-image/Agent/
See the attachment in case it should be of any help, and thanks for all your support so far.
And just to emphasize the point that with applying those changes above (missings.txt) I was able to successfully run in native mode without any error.
@gsmet @barreiro
Now that the oracle extension works I gave it a try and now I am stuck in a similar error we used to have with DB2 by this ticket.
Similar to the DB2 setup above following my setup for Oracle:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-oracle</artifactId>
</dependency>
%prod.quarkus.datasource.EAIDB.db-kind=oracle
%prod.quarkus.datasource.EAIDB.jdbc.transactions=xa
%prod.quarkus.datasource.EAIDB.jdbc.url=${EAIDB_URL}
%prod.quarkus.datasource.EAIDB.username=${EAIDB_USER}
%prod.quarkus.datasource.EAIDB.password=${EAIDB_PASS}
With this setup I get:
2022-01-28 11:12:59,825 WARN [org.apa.cam.com.jms.EndpointMessageListener] (Camel (camel-1) thread #3 - JmsConsumer[marktdepot/steuerverfahren/steuerverfahren-kista-daska-sourceadaptor/create-request-job-queue]) Execution of JMS message listener failed. Caused by: [org.apache.camel.RuntimeCamelException - java.sql.SQLException: Invalid Oracle URL specified: OracleDataSource.makeURL]: org.apache.camel.RuntimeCamelException: java.sql.SQLException: Invalid Oracle URL specified: OracleDataSource.makeURL
at org.apache.camel.component.jms.EndpointMessageListener$EndpointMessageListenerAsyncCallback.done(EndpointMessageListener.java:217)
at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:136)
at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:736)
at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:696)
at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:674)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:318)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:245)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1237)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1227)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1120)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
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)
I looked into the decompiled code of oracle.jdbc.datasource.impl.OracleDataSource
and made the conclusion that driverType
needs to be set as well, so I also added:
%prod.quarkus.datasource.EAIDB.jdbc.additional-jdbc-properties.driverType=thin
And with that I now get an additional warning for the EAIDB
datasource at startup with the same Oracle error as before:
2022-01-28 10:35:04,731 WARN [io.agr.pool] (main) Datasource 'EAIDB': Ignoring property 'URL': No setter in class oracle.jdbc.xa.client.OracleXADataSource
2022-01-28 10:35:04,733 WARN [io.agr.pool] (main) Datasource 'EAIDB': Ignoring property 'driverType': No setter in class oracle.jdbc.xa.client.OracleXADataSource
2022-01-28 10:35:04,734 WARN [io.agr.pool] (main) Datasource 'EAIDB': Available properties []
2022-01-28 10:35:04,734 WARN [io.agr.pool] (main) Datasource 'EAIDB': Ignoring property 'URL': No setter in class oracle.jdbc.xa.client.OracleXADataSource
2022-01-28 10:35:04,734 WARN [io.agr.pool] (main) Datasource 'EAIDB': Ignoring property 'driverType': No setter in class oracle.jdbc.xa.client.OracleXADataSource
2022-01-28 10:35:04,734 WARN [io.agr.pool] (main) Datasource 'EAIDB': Available properties []
2022-01-28 10:35:04,740 WARN [io.agr.pool] (main) Datasource 'P82DataSource': Ignoring property 'URL': No setter in class com.ibm.db2.jcc.DB2XADataSource
2022-01-28 10:35:04,740 WARN [io.agr.pool] (main) Datasource 'P82DataSource': Ignoring property 'URL': No setter in class com.ibm.db2.jcc.DB2XADataSource
But as far as I see there is a public void setDriverType(String driverType)
setter method there. Any idea what I am missing here? And the same question about the URL
setter method. Both DB2 & Oracle datasource implementations do provide a setter for URL
so why do we get those warnings the same as for the driverType
property?
@gsmet @barreiro Ah and just to be precise, it all works in JVM-mode. The problem here is native mode.
hi @bvahdat , could you open a new issue for the Oracle XA problem and attach a reproducer please? Ideally one without Camel as that would help me a lot :) Thanks
@Sanne from what I have seen, I think we will need adapters to properly instantiate the XA datasources.
hi @bvahdat , could you open a new issue for the Oracle XA problem and attach a reproducer please? Ideally one without Camel as that would help me a lot :) Thanks
Hi @Sanne thanks for your great support, really appreciating. You can find the reproducer here.
Back to this issue, reading the original stacktrace one can see this error reported as the cause: Can't load IA 32-bit .dll on a AMD 64-bit platform: ERRORCODE=-4472, SQLSTATE=null
I don't have a Windows machine but a quick search finds this article:
Could it be you've installed the wrong version of the driver?
Back to this issue, reading the original stacktrace one can see this error reported as the cause:
Can't load IA 32-bit .dll on a AMD 64-bit platform: ERRORCODE=-4472, SQLSTATE=null
I don't have a Windows machine but a quick search finds this article:
Could it be you've installed the wrong version of the driver?
Thanks @Sanne for the follow up. At our end it all works as expected, see also this comment. So to summarize with the following setup and adjustments (according to missings.txt
attachment above) we were able to successfully make use of the DB2 XA Driver with SSL:
%prod.quarkus.datasource.P82DataSource.db-kind=db2
%prod.quarkus.datasource.P82DataSource.jdbc.url=${P82_URL}
%prod.quarkus.datasource.P82DataSource.jdbc.additional-jdbc-properties.databaseName=${P82_DATABASE_NAME}
%prod.quarkus.datasource.P82DataSource.jdbc.additional-jdbc-properties.driverType=4
%prod.quarkus.datasource.P82DataSource.jdbc.additional-jdbc-properties.portNumber=${P82_PORT}
%prod.quarkus.datasource.P82DataSource.jdbc.additional-jdbc-properties.serverName=${P82_SERVER_NAME}
%prod.quarkus.datasource.P82DataSource.jdbc.additional-jdbc-properties.sslConnection=${P82_SSL_ENABLED:false}
%prod.quarkus.datasource.P82DataSource.jdbc.transactions=xa
%prod.quarkus.datasource.P82DataSource.username=${P82_USER}
%prod.quarkus.datasource.P82DataSource.password=${P82_PASS}
So I think at the Quarkus project side, we need some extra documentation about this as well as adjustments to the DB2 extension itself, so that bits given through missings.txt
under the folder src/main/resources/META-INF/native-image
becomes unnecessary.
Closing as it seems to be working now
Describe the bug
Running on a Windows 10 64-bit using Quarkus
2.6.1.Final
following the relevant dependencies I have for connecting to a DB2 instance:The settings in
application.properties
are as the folloiwng:The value of
P82_URL
isjdbc:db2://<IP_ADDRESS>:446/<DATABASE_NAME>
.The application runs without any issue using this setup as one can see below (both in JVM as well as native mode):
Now if I ask for the XA driver using:
Then the application fails to load the XA driver with the following message on startup:
The file
C:\Program Files (x86)\IBM\SQLLIB\BIN\db2jcct2.dll
is existing on the machine. I have also WSL on the same machine. Again using plain JDBC driver works perfectly but switching to XA driver results in a similar error:The warning message at the very first begining seems to be from: https://github.com/agroal/agroal/blob/master/agroal-pool/src/main/java/io/agroal/pool/util/PropertyInjector.java#L46
Any help is much appreciated.
cc: @gsmet @barreiro @aguibert
Expected behavior
I expect to see the XA Driver usage works the same as the JDBC driver.
Actual behavior
The usage of XA Driver fails.
How to Reproduce?
No response
Output of
uname -a
orver
MINGW64_NT-10.0-18363 XYZ 3.1.7-340.x86_64 2021-10-12 16:29 UTC x86_64 Msys
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.1.Final
Build tool (ie. output of
mvnw --version
orgradlew --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