rei*_*mai 1 java spring c3p0 quartz-scheduler maven
我已经发现了问题所在,但决定把它贴在这里,以防其他任何人撞到同一堵墙.
我已将最新版本的quartz scheduler添加到我的项目中:
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.2.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
并且突然测试开始下降:
org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [ my sql ]; SQL state [null]; error code [0]; An SQLException was provoked by the following failure: java.lang.InterruptedException; nested exception is java.sql.SQLException: An SQLException was provoked by the following failure: java.lang.InterruptedException
Run Code Online (Sandbox Code Playgroud)
更奇怪的是,当我将石英依赖转移到另一个模块时,它们开始失败,但有不同的例外:
Could not get JDBC Connection; nested exception is java.sql.SQLException: com.mchange.v2.c3p0.ComboPooledDataSource[ identityToken -> z8kfsx9b1qeyobp10iytmq|796c39ad, dataSourceName -> z8kfsx9b1qeyobp10iytmq|796c39ad ] has been closed() -- you can no longer use it.
Run Code Online (Sandbox Code Playgroud)
所以,Spring关闭了我的ComboPooledDataSource,但为什么呢?
删除石英或将其版本更改为1.8.x有助于.即使没有实例化任何石英对象也会发生异常.
c3p0从版本2.x开始,Quartz使用jdbc池作为它的分布式作业存储,我的项目也使用c3p0,但是更新0.9.5版本,而石英使用0.9.1.1.这些版本是完全不同的,来自quartz的旧版本在我的类路径中排在第一位,导致运行时异常.由于我不使用石英分布式作业存储,我通过排除传递c3p0依赖性解决了这个问题:
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.2.1</version>
<!-- old c3p0 (0.9.1.1) in class path causes destruction of ComboPooledDataSource-->
<exclusions>
<exclusion>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
</exclusion>
</exclusions>
</dependency>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1720 次 |
| 最近记录: |