question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Usage of DB2 XA Driver ends up with error com.ibm.db2.jcc.am.SqlException: [jcc][10389][12245][4.29.24] Failure in loading native library db2jcct2, java.lang.UnsatisfiedLinkError

See original GitHub issue

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:

<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-agroal</artifactId>
</dependency>
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-jdbc-db2</artifactId>
</dependency>
<dependency>
    <groupId>com.ibm.db2.jcc</groupId>
    <artifactId>db2jcc_license_cisuz</artifactId>
    <version>11.1</version>
</dependency>

The settings in application.properties are as the folloiwng:

%prod.quarkus.datasource.P82DataSource.db-kind=${P82_KIND:db2}
%prod.quarkus.datasource.P82DataSource.jdbc.url=${P82_URL}
%prod.quarkus.datasource.P82DataSource.username=${P82_USER}
%prod.quarkus.datasource.P82DataSource.password=${P82_PASS}

The value of P82_URL is jdbc: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):

...
2022-01-07 04:24:42,704 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 3.14.0 (camel-1) started in 401ms (build:0ms init:385ms start:16ms)
2022-01-07 04:24:42,820 INFO  [io.quarkus] (main) my-app 1.0.0-SNAPSHOT on JVM (powered by Quarkus 2.6.1.Final) started in 2.211s. Listening on: http://0.0.0.0:8080
2022-01-07 04:24:42,820 INFO  [io.quarkus] (main) Profile prod activated.
2022-01-07 04:24:42,820 INFO  [io.quarkus] (main) Installed features: [agroal, artemis-jms, camel-core, camel-direct, camel-jms, camel-jta, camel-log, camel-micrometer, camel-microprofile-health, camel-xpath, camel-xslt, cdi, jdbc-db2, jdbc-h2, micrometer, narayana-jta, smallrye-context-propagation, smallrye-health, vertx]
...

Now if I ask for the XA driver using:

%prod.quarkus.datasource.P82DataSource.jdbc.transactions=xa

Then the application fails to load the XA driver with the following message on startup:

2022-01-07 04:25:51,916 WARN  [io.agr.pool] (main) Datasource 'P82DataSource': Ignoring property 'URL': No setter in class com.ibm.db2.jcc.DB2XADataSource
2022-01-07 04:25:51,916 WARN  [io.agr.pool] (main) Datasource 'P82DataSource': Ignoring property 'URL': No setter in class com.ibm.db2.jcc.DB2XADataSource
...
...
2022-01-07 04:25:52,918 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 3.14.0 (camel-1) started in 432ms (build:0ms init:400ms start:32ms)
2022-01-07 04:25:53,013 INFO  [io.quarkus] (main) my-app 1.0.0-SNAPSHOT on JVM (powered by Quarkus 2.6.1.Final) started in 1.946s. Listening on: http://0.0.0.0:8080
2022-01-07 04:25:53,013 INFO  [io.quarkus] (main) Profile prod activated.
2022-01-07 04:25:53,013 INFO  [io.quarkus] (main) Installed features: [agroal, artemis-jms, camel-core, camel-direct, camel-jms, camel-jta, camel-log, camel-micrometer, camel-microprofile-health, camel-xpath, camel-xslt, cdi, jdbc-db2, jdbc-h2, micrometer, narayana-jta, smallrye-context-propagation, smallrye-health, vertx]
com.ibm.db2.jcc.am.SqlException: [jcc][10389][12245][4.29.24] Failure in loading native library db2jcct2, java.lang.UnsatisfiedLinkError: C:\Program Files (x86)\IBM\SQLLIB\BIN\db2jcct2.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform:  ERRORCODE=-4472, SQLSTATE=null
        at com.ibm.db2.jcc.am.b7.a(b7.java:794)
        at com.ibm.db2.jcc.am.b7.a(b7.java:66)
        at com.ibm.db2.jcc.am.b7.a(b7.java:107)
        at com.ibm.db2.jcc.t2.a.a(a.java:37)
        at com.ibm.db2.jcc.t2.T2Configuration.<clinit>(T2Configuration.java:95)
        at com.ibm.db2.jcc.DB2BaseDataSource.instantiateLogWriter(DB2BaseDataSource.java:12359)
        at com.ibm.db2.jcc.DB2BaseDataSource.computeJccLogWriterForNewConnection(DB2BaseDataSource.java:12271)
        at com.ibm.db2.jcc.DB2BaseDataSource.computeJccLogWriterForNewConnection(DB2BaseDataSource.java:12224)
        at com.ibm.db2.jcc.DB2XADataSource.getXAConnection(DB2XADataSource.java:159)
        at com.ibm.db2.jcc.DB2XADataSource.getXAConnection(DB2XADataSource.java:134)
        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.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at io.agroal.pool.util.PriorityScheduledExecutor.beforeExecute(PriorityScheduledExecutor.java:75)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)
com.ibm.db2.jcc.am.SqlException: [jcc][10389][12245][4.29.24] Failure in loading native library db2jcct2, java.lang.UnsatisfiedLinkError: C:\Program Files (x86)\IBM\SQLLIB\BIN\db2jcct2.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform:  ERRORCODE=-4472, SQLSTATE=null
        at com.ibm.db2.jcc.am.b7.a(b7.java:794)
        at com.ibm.db2.jcc.am.b7.a(b7.java:66)
        at com.ibm.db2.jcc.am.b7.a(b7.java:107)
        at com.ibm.db2.jcc.t2.a.a(a.java:37)
        at com.ibm.db2.jcc.t2.T2Configuration.<clinit>(T2Configuration.java:95)
        at com.ibm.db2.jcc.DB2BaseDataSource.instantiateLogWriter(DB2BaseDataSource.java:12359)
        at com.ibm.db2.jcc.DB2BaseDataSource.computeJccLogWriterForNewConnection(DB2BaseDataSource.java:12271)
        at com.ibm.db2.jcc.DB2BaseDataSource.computeJccLogWriterForNewConnection(DB2BaseDataSource.java:12224)
        at com.ibm.db2.jcc.DB2XADataSource.getXAConnection(DB2XADataSource.java:159)
        at com.ibm.db2.jcc.DB2XADataSource.getXAConnection(DB2XADataSource.java:134)
        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.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at io.agroal.pool.util.PriorityScheduledExecutor.beforeExecute(PriorityScheduledExecutor.java:75)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)
...

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:

2022-01-07 04:28:52,993 WARN  [io.agr.pool] (main) Datasource 'P82DataSource': Ignoring property 'URL': No setter in class com.ibm.db2.jcc.DB2XADataSource
2022-01-07 04:28:52,993 WARN  [io.agr.pool] (main) Datasource 'P82DataSource': Ignoring property 'URL': No setter in class com.ibm.db2.jcc.DB2XADataSource
...
...
2022-01-07 04:28:53,759 INFO  [io.quarkus] (main) my-app 1.0.0-SNAPSHOT on JVM (powered by Quarkus 2.6.1.Final) started in 1.632s. Listening on: http://0.0.0.0:8080
2022-01-07 04:28:53,760 INFO  [io.quarkus] (main) Profile prod activated.
2022-01-07 04:28:53,760 INFO  [io.quarkus] (main) Installed features: [agroal, artemis-jms, camel-core, camel-direct, camel-jms, camel-jta, camel-log, camel-micrometer, camel-microprofile-health, camel-xpath, camel-xslt, cdi, jdbc-db2, jdbc-h2, micrometer, narayana-jta, smallrye-context-propagation, smallrye-health, vertx]
com.ibm.db2.jcc.am.SqlException: [jcc][10389][12245][4.29.24] Failure in loading native library db2jcct2, java.lang.UnsatisfiedLinkError: no db2jcct2 in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib:  ERRORCODE=-4472, SQLSTATE=null
        at com.ibm.db2.jcc.am.b7.a(b7.java:794)
        at com.ibm.db2.jcc.am.b7.a(b7.java:66)
        at com.ibm.db2.jcc.am.b7.a(b7.java:107)
        at com.ibm.db2.jcc.t2.a.a(a.java:37)
        at com.ibm.db2.jcc.t2.T2Configuration.<clinit>(T2Configuration.java:95)
        at com.ibm.db2.jcc.DB2BaseDataSource.instantiateLogWriter(DB2BaseDataSource.java:12359)
        at com.ibm.db2.jcc.DB2BaseDataSource.computeJccLogWriterForNewConnection(DB2BaseDataSource.java:12271)
        at com.ibm.db2.jcc.DB2BaseDataSource.computeJccLogWriterForNewConnection(DB2BaseDataSource.java:12224)
        at com.ibm.db2.jcc.DB2XADataSource.getXAConnection(DB2XADataSource.java:159)
        at com.ibm.db2.jcc.DB2XADataSource.getXAConnection(DB2XADataSource.java:134)
        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.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at io.agroal.pool.util.PriorityScheduledExecutor.beforeExecute(PriorityScheduledExecutor.java:75)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)
com.ibm.db2.jcc.am.SqlException: [jcc][10389][12245][4.29.24] Failure in loading native library db2jcct2, java.lang.UnsatisfiedLinkError: no db2jcct2 in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib:  ERRORCODE=-4472, SQLSTATE=null
        at com.ibm.db2.jcc.am.b7.a(b7.java:794)
        at com.ibm.db2.jcc.am.b7.a(b7.java:66)
        at com.ibm.db2.jcc.am.b7.a(b7.java:107)
        at com.ibm.db2.jcc.t2.a.a(a.java:37)
        at com.ibm.db2.jcc.t2.T2Configuration.<clinit>(T2Configuration.java:95)
        at com.ibm.db2.jcc.DB2BaseDataSource.instantiateLogWriter(DB2BaseDataSource.java:12359)
        at com.ibm.db2.jcc.DB2BaseDataSource.computeJccLogWriterForNewConnection(DB2BaseDataSource.java:12271)
        at com.ibm.db2.jcc.DB2BaseDataSource.computeJccLogWriterForNewConnection(DB2BaseDataSource.java:12224)
        at com.ibm.db2.jcc.DB2XADataSource.getXAConnection(DB2XADataSource.java:159)
        at com.ibm.db2.jcc.DB2XADataSource.getXAConnection(DB2XADataSource.java:134)
        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.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at io.agroal.pool.util.PriorityScheduledExecutor.beforeExecute(PriorityScheduledExecutor.java:75)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)
...

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 or ver

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 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

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Sannecommented, Jan 31, 2022

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

1reaction
bvahdatcommented, Jan 11, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failure in loading native library db2jcct2, UnsatisfiedLinkError
Symptom. Applications failing to load the Data Server Driver for a Type 2 connection may return one of the following messages:.
Read more >
java.lang.UnsatisfiedLinkError while loading DB2 JDBC driver
I try to use jboss-seam with a db2 database, the following error occurs com.ibm.
Read more >
"Failure in loading T2 native library db2jcct2" Error With ...
com.ibm.db2.jcc.b.SqlException: Failure in loading T2 native library db2jcct2, reason: java.lang.UnsatisfiedLinkError: /usr/java14/j
Read more >
Failure in loading native library db2jcct2, java.lang ... - Red Hat
I modified spring-boot-camel-xa-transaction to simulate the DB2 error. When I use spring-boot's datasource autoconfiguration feature, I hit this issue with DB2 ...
Read more >
driver « db2 « Java Database Q&A - Java2s.com
com.ibm.db2.jcc.a.SqlException: [jcc][10389][12245][3.52.95] while loading the native library db2jcct2, java.lang.UnsatisfiedLinkError: no db2jcct2 in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found