我们已经配置了一个基于 xml 的石英作业,它在 java 7 上运行良好,但升级到 java 8 后,该作业在 2、3 次迭代后挂起,无论 cron 表达式是什么,我们每 5 秒测试一次。 我们怀疑问题可能是因为数据库连接丢失而没有任何错误或连接池为空,或者可能是VFS2库。 (但是我们创建了一个简单的应用程序,它与 sftp 连接并使用 JDBC 进行一些简单的数据库操作,并且它运行没有任何问题)。
jdbc.driverClassName=net.sourceforge.jtds.jdbc.Drivercom.microsoft.sqlserver.jdbc.SQLServerDriver
jdbc.url=jdbc:jtds:sqlserver://SERVER_ADDRESS:1433/SERVER_NAME
jdbc.username=USER
jdbc.password=PASS
jdbc.initialSize=5
jdbc.maxTotal=150
jdbc.maxIdle=15
jdbc.minIdle=5
jdbc.maxWaitMillis=10000
jdbc.validationQuery=SELECT 1
jdbc.validationQueryTimeout=10
jdbc.testOnBorrow=true
jdbc.testOnReturn=false
jdbc.testWhileIdle=false
jdbc.timeBetweenEvictionRunsMillis=1803000
jdbc.minEvictableIdleTimeMillis=1800000
jdbc.removeAbandonedOnMaintenance=true
jdbc.removeAbandonedOnBorrow=true
jdbc.removeAbandonedTimeout=300
jdbc.logAbandoned=true
我们正在使用基于maven的java 8项目,java的确切版本是:jdk1.8.0_311。 这个ia web应用程序部署在tomcat8.5上,我们也尝试过tomcat 9,但没有成功
主要依赖有: SPRING4,hibernate3.6.9.Final,Apache commons-vfs2版本2.7.0,数据库是sqlServer
这些是quartz作业的xml bean定义:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.5.xsd">
<bean id="automaticInterviewImportJob" class="cem.interview.importtool.quartz.InterviewImportJob" scope = "singleton">
</bean>
<bean id="automaticReportGenerationJob" class="cem.interview.importtool.quartz.ReportGenerationJob" scope = "singleton">
</bean>
<!-- Address import job -->
<bean id="automaticInterviewImportJobDetail"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="automaticInterviewImportJob" />
<property name="targetMethod" value="run" />
<property name="concurrent" value="false"/>
</bean>
<bean id="automaticInterviewImportJobTriger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<!-- class="org.springframework.scheduling.quartz.SimpleTriggerBean"> -->
<property name="jobDetail" ref="automaticInterviewImportJobDetail"/>
<property name="cronExpression" value="0/5 * * * * ? *"/>
</bean>
<!-- Address import job -->
<bean id="automaticGenerateExcelReportsJobDetail"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="automaticReportGenerationJob" />
<property name="targetMethod" value="run" />
<property name="concurrent" value="false"/>
</bean>
<bean id="automaticGenerateExcelReportJobTriger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<!-- class="org.springframework.scheduling.quartz.SimpleTriggerBean"> -->
<property name="jobDetail" ref="automaticGenerateExcelReportsJobDetail"/>
<property name="cronExpression" value="0/5 * * * * ? *"/>
</bean>
<bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="applicationContextSchedulerContextKey" value="applicationContext" />
<property name="waitForJobsToCompleteOnShutdown" value="true" />
<property name="jobFactory">
<bean class="org.springframework.scheduling.quartz.SpringBeanJobFactory"/>
</property>
<property name="globalJobListeners">
<list>
</list>
</property>
<property name="triggers">
<list>
<ref bean="automaticInterviewImportJobTriger" />
<ref bean="automaticGenerateExcelReportJobTriger" />
</list>
</property>
</bean>
</beans>
您使用什么石英版本?确保您使用 Quartz 2.4.0+。较低的所有内容 - 与 Java 8 不兼容。
是否可能出现以下情况:使用旧 Java 版本的应用程序的其他实例连接到数据库中某些作业的同一数据库获取锁并失败?换句话说,请确保在连接到此数据库的所有应用程序实例上更新 JDK。