2011-12-15 124 views
0

Spring Batch似乎與它所調用的ejbs在同一個事務中運行。因此,當我們在ejbs中獲得回滾時,Spring Batch無法更新其在數據庫中的狀態。Spring批處理由於RollbackException而無法更新其狀態

我們得到的唯一的例外是:

org.springframework.batch.core.step.FatalStepExecutionException: JobRepository failure forcing exit with unknown status 
    at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:418) 
    at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130) 
    at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:262) 
    at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:76) 
    at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:367) 
    at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:214) 
    at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143) 
    at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:248) 
    at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:195) 
    at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:135) 
    at org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:61) 
    at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:60) 
    at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:144) 
    at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:124) 
    at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:135) 
    at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:281) 
    at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:120) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 
    at java.lang.Thread.run(Thread.java:662) 
Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Error in allocating a connection. Cause: javax.transaction.RollbackException 

我們怎樣才能確保Spring Batch的是能夠即使步驟失敗更新其狀態?這是Spring Batch中的一個錯誤,還是我們做錯了什麼?

回答

-2

似乎問題出在我們配置的工作臺上。

我們有一些進程啓動其他進程,當他們使用相同的taskExecutor實例時,回滾回滾任務本身。

不是100%肯定,如果這是什麼固定的錯誤,但它的工作現在:-)

-1

批處理是否也在ejb中運行?什麼是ejbs的交易設置? BMT或CMT?從批處理的哪個位置調用EJB?讀者,處理器,作家?監聽?你是否試圖通過代碼中的常規catch(Exception e)處理導致ejb上的回滾的異常,跳過或重試?

+0

好像我們有一些停止的進程畢竟。我們在作家中引用ejbs。不,我們沒有處理所有例外。我們讓它們失敗,然後我們有另一個過程在一段時間後重新啓動它們。 – olemartin 2011-12-16 11:57:25