Failed to obtain JDBC Connection when using spring with jndi on liberty

岁酱吖の 提交于 2020-04-30 14:05:27

问题


When running load-test when running the application on liberty, and getting the datasource from liberty via JNDI, the test fails after a minute or so with the exception:

Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLTransientConnectionException: J2CA0045E: Connection not available while invoking method createOrWaitForConnection for resource jdbc/MY_JNDI_NAME. Timed out waiting for 30,000 millisecond(s) with 29 remaining waiting requests and 10 current total connections used.

When configuring the datasource directly in the spring-application (and thus using HikariCP as the connection pool), the same test runs successfully for 10 minutes.

Have tried excluding hikaricp dependency from the application to ensure that hikari doesn't involve itself somehow.

edit1: There seems to be some different behavior when doing the same call. Here from spring (does commit and afterCommit):

2019-05-15 13:03:09.855 TRACE 93902 --- [nio-8070-exec-3] o.s.j.d.DataSourceTransactionManager     : Triggering beforeCommit synchronization
2019-05-15 13:03:09.855 TRACE 93902 --- [nio-8070-exec-3] o.s.j.d.DataSourceTransactionManager     : Triggering beforeCompletion synchronization
2019-05-15 13:03:09.855 DEBUG 93902 --- [nio-8070-exec-3] o.s.j.d.DataSourceTransactionManager     : Initiating transaction commit
2019-05-15 13:03:09.855 DEBUG 93902 --- [nio-8070-exec-3] o.s.j.d.DataSourceTransactionManager     : Committing JDBC transaction on Connection [HikariProxyConnection@942192123 wrapping oracle.jdbc.driver.T4CConnection@38af1bf6]
2019-05-15 13:03:09.863 TRACE 93902 --- [nio-8070-exec-3] o.s.j.d.DataSourceTransactionManager     : Triggering afterCommit synchronization
2019-05-15 13:03:09.863 TRACE 93902 --- [nio-8070-exec-3] .s.t.s.TransactionSynchronizationManager : Clearing transaction synchronization
2019-05-15 13:03:09.863 TRACE 93902 --- [nio-8070-exec-3] o.s.j.d.DataSourceTransactionManager     : Triggering afterCompletion synchronization
2019-05-15 13:03:09.863 TRACE 93902 --- [nio-8070-exec-3] .s.t.s.TransactionSynchronizationManager : Removed value [org.springframework.jdbc.datasource.ConnectionHolder@550224fb] for key [HikariDataSource (DS-RGVALIDATION)] from thread [http-nio-8070-exec-3]

here is the same call from liberty:

[5/16/19 9:31:37:556 CEST] 0000002a id=00000000 ework.transaction.support.AbstractPlatformTransactionManager 3 triggerBeforeCommit Triggering beforeCommit synchronization
[5/16/19 9:31:37:557 CEST] 0000002a id=00000000 ework.transaction.support.AbstractPlatformTransactionManager 3 triggerBeforeCompletion Triggering beforeCompletion synchronization
[5/16/19 9:31:37:558 CEST] 0000002a id=00000000 mework.transaction.support.TransactionSynchronizationManager 3 doUnbindResource Removed value [org.springframework.jdbc.datasource.ConnectionHolder@ec5e4040] for key [com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource@5596007b] from thread [Default Executor-thread-2]

Both calls end with TransactionSynchronizationManager removing the value keyed on the datasource

来源:https://stackoverflow.com/questions/56131721/failed-to-obtain-jdbc-connection-when-using-spring-with-jndi-on-liberty

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!