我有一个令人困惑的问题,我已经与他斗争了几天,其原因似乎是相当难以捉摸的。简而言之,我在特定工作中有三个步骤,并且在步骤#2之后工作总是失败。我已经验证正在执行的Tasklet正在按预期返回,监听器afterStep指示ExitStatus的预期返回值是“CONTINUE”,但是它从未到达beforeStep以进行下一步,表明作业已失败。我已经逐步完成了代码,发现它在SImpleJobLauncher.run失败了。我将日志设置为跟踪,我相信我已经确定了第一次出现此问题的位置。
2017-06-15 10:24:42 [jobLauncherTaskExecutor-2] DEBUG o.s.batch.core.step.AbstractStep.execute 281 - Step execution complete: StepExecution: id=3397, version=3, name=STEP THAT ISN'T RUNNING, status=COMPLETED, exitStatus=CONTINUE, readCount=0, filterCount=0, writeCount=0 readSkipCount=0, writeSkipCount=0, processSkipCount=0, commitCount=1, rollbackCount=0
2017-06-15 10:24:42 [jobLauncherTaskExecutor-2] DEBUG o.s.t.s.AbstractPlatformTransactionManager.getTransaction 367 - Creating new transaction with name [org.springframework.batch.core.repository.support.SimpleJobRepository.updateExecutionContext]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2017-06-15 10:24:42 [jobLauncherTaskExecutor-2] DEBUG o.s.j.d.DataSourceTransactionManager.doBegin 248 - Acquired Connection [jdbc:oracle:thin:@localhost:1521:orcl, UserName=USERNAME, Oracle JDBC driver] for JDBC transaction
2017-06-15 10:24:42 [jobLauncherTaskExecutor-2] DEBUG o.s.j.d.DataSourceTransactionManager.doBegin 265 - Switching JDBC Connection [jdbc:oracle:thin:@localhost:1521:orcl, UserName=USERNAME, Oracle JDBC driver] to manual commit
2017-06-15 10:24:42 [jobLauncherTaskExecutor-2] TRACE o.s.t.s.TransactionSynchronizationManager.bindResource 193 - Bound value [org.springframework.jdbc.datasource.ConnectionHolder@4ab1bdf6] for key [org.apache.commons.dbcp.BasicDataSource@58aa1d72] to thread [jobLauncherTaskExecutor-2]
2017-06-15 10:24:42 [jobLauncherTaskExecutor-2] TRACE o.s.t.s.TransactionSynchronizationManager.initSynchronization 272 - Initializing transaction synchronization
2017-06-15 10:24:42 [jobLauncherTaskExecutor-2] TRACE o.s.t.i.TransactionAspectSupport.prepareTransactionInfo 474 - Getting transaction for [org.springframework.batch.core.repository.support.SimpleJobRepository.updateExecutionContext]
2017-06-15 10:24:42 [jobLauncherTaskExecutor-2] DEBUG o.s.jdbc.core.JdbcTemplate.update 869 - Executing prepared SQL update
2017-06-15 10:24:42 [jobLauncherTaskExecutor-2] DEBUG o.s.jdbc.core.JdbcTemplate.execute 616 - Executing prepared SQL statement [**UPDATE BATCH_JOB_EXECUTION_CONTEXT SET SHORT_CONTEXT = ?, SERIALIZED_CONTEXT = ? WHERE JOB_EXECUTION_ID = ?**]
2017-06-15 10:24:42 [jobLauncherTaskExecutor-2] TRACE o.s.t.s.TransactionSynchronizationManager.getResource 140 - Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@4ab1bdf6] for key [org.apache.commons.dbcp.BasicDataSource@58aa1d72] bound to thread [jobLauncherTaskExecutor-2]
2017-06-15 10:24:42 [jobLauncherTaskExecutor-2] TRACE o.s.t.s.TransactionSynchronizationManager.getResource 140 - Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@4ab1bdf6] for key [org.apache.commons.dbcp.BasicDataSource@58aa1d72] bound to thread [jobLauncherTaskExecutor-2]
2017-06-15 10:24:42 [jobLauncherTaskExecutor-2] DEBUG o.s.jdbc.core.JdbcTemplate$2.doInPreparedStatement 879 - SQL update affected 1 rows
2017-06-15 10:24:42 [jobLauncherTaskExecutor-2] TRACE o.s.t.s.TransactionSynchronizationManager.getResource 140 - Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@4ab1bdf6] for key [org.apache.commons.dbcp.BasicDataSource@58aa1d72] bound to thread [jobLauncherTaskExecutor-2]
2017-06-15 10:24:42 [jobLauncherTaskExecutor-2] TRACE o.s.t.i.TransactionAspectSupport.commitTransactionAfterReturning 502 - Completing transaction for [org.springframework.batch.core.repository.support.SimpleJobRepository.updateExecutionContext]
2017-06-15 10:24:42 [jobLauncherTaskExecutor-2] TRACE o.s.t.s.AbstractPlatformTransactionManager.triggerBeforeCommit 930 - Triggering beforeCommit synchronization
2017-06-15 10:24:42 [jobLauncherTaskExecutor-2] TRACE o.s.t.s.AbstractPlatformTransactionManager.triggerBeforeCompletion 943 - Triggering beforeCompletion synchronization
2017-06-15 10:24:42 [jobLauncherTaskExecutor-2] DEBUG o.s.t.s.AbstractPlatformTransactionManager.processCommit 759 - Initiating transaction commit
2017-06-15 10:24:42 [jobLauncherTaskExecutor-2] DEBUG o.s.j.d.DataSourceTransactionManager.doCommit 310 - Committing JDBC transaction on Connection [jdbc:oracle:thin:@localhost:1521:orcl, UserName=USERNAME, Oracle JDBC driver]
2017-06-15 10:24:42 [jobLauncherTaskExecutor-2] TRACE o.s.t.s.AbstractPlatformTransactionManager.triggerAfterCommit 956 - Triggering afterCommit synchronization
2017-06-15 10:24:42 [jobLauncherTaskExecutor-2] TRACE o.s.t.s.TransactionSynchronizationManager.clearSynchronization 331 - Clearing transaction synchronization
2017-06-15 10:24:42 [jobLauncherTaskExecutor-2] TRACE o.s.t.s.AbstractPlatformTransactionManager.triggerAfterCompletion 973 - Triggering afterCompletion synchronization
2017-06-15 10:24:42 [jobLauncherTaskExecutor-2] TRACE o.s.t.s.TransactionSynchronizationManager.doUnbindResource 243 - Removed value [org.springframework.jdbc.datasource.ConnectionHolder@4ab1bdf6] for key [org.apache.commons.dbcp.BasicDataSource@58aa1d72] from thread [jobLauncherTaskExecutor-2]
2017-06-15 10:24:42 [jobLauncherTaskExecutor-2] DEBUG o.s.j.d.DataSourceTransactionManager.doCleanupAfterCompletion 368 - Releasing JDBC Connection [jdbc:oracle:thin:@localhost:1521:orcl, UserName=USERNAME, Oracle JDBC driver] after transaction
2017-06-15 10:24:42 [jobLauncherTaskExecutor-2] DEBUG o.s.jdbc.datasource.DataSourceUtils.doReleaseConnection 327 - Returning JDBC Connection to DataSource
2017-06-15 10:24:42 [jobLauncherTaskExecutor-2] DEBUG o.s.b.c.job.flow.support.SimpleFlow.resume 183 - Completed state=JOB NAME.STEP THAT ISN'T RUNNING with status=CONTINUE
2017-06-15 10:24:42 [jobLauncherTaskExecutor-2] DEBUG o.s.b.c.job.flow.support.SimpleFlow.resume 167 - Handling state=JOB NAME.FAILED
2017-06-15 10:24:42 [jobLauncherTaskExecutor-2] DEBUG o.s.b.c.job.flow.support.SimpleFlow.resume 183 - Completed state=JOB NAME.FAILED with status=FAILED
2017-06-15 10:24:42 [jobLauncherTaskExecutor-2] DEBUG o.s.batch.core.job.AbstractJob.execute 308 - Job execution complete: JobExecution: id=1224, version=1, startTime=Thu Jun 15 10:24:42 EDT 2017, endTime=null, lastUpdated=Thu Jun 15 10:24:42 EDT 2017, status=FAILED, exitStatus=exitCode=FAILED;exitDescription=, job=[JobInstance: id=871, version=0, Job=[JOB NAME]], jobParameters=[{timestamp=1497536682001}]
作业设置如下。它使用java注释而不是xml
@Autowired
private JobBuilderFactory jobBuilderFactory;
@Bean
public Job importCostDataJob(@Qualifier("firstStep") Step firstStep,
@Qualifier("secondStep") Step secondStep,
@Qualifier("stepThatIsntRunning") Step stepThatIsntRunning,
@Qualifier("customJobListener") CustomJobListener customJobListener
) {
return jobBuilderFactory.get("JOB NAME")
.incrementer(new RunIdIncrementer())
.listener(customJobListener)
.flow(firstStep)
.next(secondStep)
.next(stepThatIsntRunning)
.build()
.build();
}
我能想到的最接近的事情是无论出于何种原因,粗体的SQL查询导致了这个问题,但我看不出有怎样或为什么?对于失败的步骤而言,它并没有达到听众的程度,所以我不确定在哪里可以检查它可能会对此有所了解。
其他任何人都遇到过这种情况?