Announcement Announcement Module
Collapse
No announcement yet.
Exception in Spring Batch is causing rollback Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exception in Spring Batch is causing rollback

    I am processing the records from CSV and if I get an exeption the entire transaction is getting rolledback.
    I have used skip and no roll back both are not working.
    ERROR 2012-11-20 09:48:58,626 org.springframework.batch.core.step.AbstractStep - Encountered an error executing the step
    org.springframework.transaction.UnexpectedRollback Exception: Transaction rolled back because it has been marked as rollback-only
    at org.springframework.transaction.support.AbstractPl atformTransactionManager.commit(AbstractPlatformTr ansactionManager.java:717)
    at org.springframework.transaction.support.Transactio nTemplate.execute(TransactionTemplate.java:147)
    at org.springframework.batch.core.step.tasklet.Taskle tStep$2.doInChunkContext(TaskletStep.java:263)
    at org.springframework.batch.core.scope.context.StepC ontextRepeatCallback.doInIteration(StepContextRepe atCallback.java:76)
    at org.springframework.batch.repeat.support.RepeatTem plate.getNextResult(RepeatTemplate.java:367)
    at org.springframework.batch.repeat.support.RepeatTem plate.executeInternal(RepeatTemplate.java:214)
    at org.springframework.batch.repeat.support.RepeatTem plate.iterate(RepeatTemplate.java:143)
    at org.springframework.batch.core.step.tasklet.Taskle tStep.doExecute(TaskletStep.java:248)
    at org.springframework.batch.core.step.AbstractStep.e xecute(AbstractStep.java:195)
    at org.springframework.batch.core.job.SimpleStepHandl er.handleStep(SimpleStepHandler.java:135)
    at org.springframework.batch.core.job.flow.JobFlowExe cutor.executeStep(JobFlowExecutor.java:61)
    at org.springframework.batch.core.job.flow.support.st ate.StepState.handle(StepState.java:60)
    at org.springframework.batch.core.job.flow.support.Si mpleFlow.resume(SimpleFlow.java:144)
    at org.springframework.batch.core.job.flow.support.Si mpleFlow.start(SimpleFlow.java:124)
    at org.springframework.batch.core.job.flow.FlowJob.do Execute(FlowJob.java:135)
    at org.springframework.batch.core.job.AbstractJob.exe cute(AbstractJob.java:281)
    at org.springframework.batch.core.launch.support.Simp leJobLauncher$1.run(SimpleJobLauncher.java:120)
    at org.springframework.core.task.SyncTaskExecutor.exe cute(SyncTaskExecutor.java:48)
    at org.springframework.batch.core.launch.support.Simp leJobLauncher.run(SimpleJobLauncher.java:114)
    at org.springframework.batch.core.launch.support.Comm andLineJobRunner.start(CommandLineJobRunner.java:3 48)
    at org.springframework.batch.core.launch.support.Comm andLineJobRunner.main(CommandLineJobRunner.java:56 5)

  • #2
    Can we see your job's configuration?

    Comment


    • #3
      configuration

      Code:
      <beans:import resource="classpath:plugin/sis/client/plugin.xml"/>         
      
      	<beans:bean id="jobLauncher"
      		class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
      		<beans:property name="jobRepository" ref="jobRepository" />
      	</beans:bean>
      
      	<beans:bean id="jobRepository"
      		class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
      		<beans:property name="dataSource" ref="dataSource" />
      		<beans:property name="transactionManager" ref="transactionManager" />
      	</beans:bean>
      
      	<job id="UOSBatchJob">
      		<step id="step-1" next="step0">
      			<tasklet ref="newExtractCheck" />
      		</step>
      		<step id="step0">
      			<tasklet ref="loadAcademicSessions" />
      			<next on="FAILED" to="step9" />
      			<next on="*" to="step0.5" />
      		</step>
      		<step id="step0.5">
      			<tasklet ref="templateBucketTasklet" />
      			<next on="*" to="step1" />
      		</step>
      		<step id="step1" next="step2"> 
      			<tasklet ref="updateCoursesTasklet" />
      		</step>
      		<!--  
      			  In step1, the course update, some learner might be moved from a closing
      			  section into an open one.  If this happens and if some of those learners
      			  have other changes in the extract (such as status change, session change, etc)
      			  there might be some mishandling of the simultaneous changes.
      			  For this reason, go ahead and deal with those potential Vista registration
      			  at this point, before the extract is read
      		 -->
      		<step id="step2" next="step3">
      			<tasklet> 
      				<chunk reader="registerReader" writer="registerWriter" processor="preRegisterProcessor" commit-interval="1" skip-limit="10">
      					<skippable-exception-classes>
      						<!-- To skip all the exceptions -->
      						<include class="java.lang.Exception"/>	
      						<include class="java.lang.Throwable"/>				 		
      					</skippable-exception-classes>
      				</chunk>
      				<no-rollback-exception-classes>
      					<!-- To skip all the exceptions -->
      					<include class="java.lang.Exception"/>
      					<include class="java.lang.Throwable"/>							 	
      				</no-rollback-exception-classes>
      			</tasklet>
      		</step>
      		<step id="step3" next="step3.5">
      			<tasklet>
      				<chunk reader="registerReader" writer="registerWriter" processor="registerProcessor" commit-interval="1" skip-limit="10">
      					<skippable-exception-classes>
      						<!-- To skip all the exceptions -->
      						<include class="java.lang.Exception"/>	
      						<include class="java.lang.Throwable"/>					 		
      					</skippable-exception-classes>
      				</chunk>
      				<no-rollback-exception-classes>
      					<!-- To skip all the exceptions -->
      					<include class="java.lang.Exception"/>
      					<include class="java.lang.Throwable"/>							 	
      				</no-rollback-exception-classes>
      			</tasklet>
      		</step>
      		<step id="step3.5" next="step4">
      			<tasklet>
      				<chunk reader="extractReader" writer="extractWriter" processor="multipleProgramsProcessor" commit-interval="1" skip-limit="10" >
      					<skippable-exception-classes>
      						<!-- To skip all the exceptions -->
      						<include class="java.lang.Exception"/>
      						<include class="java.lang.Throwable"/>		
      					 	<include class="org.springframework.batch.item.file.FlatFileParseException"/>
      					</skippable-exception-classes>
      				</chunk>
      				<no-rollback-exception-classes>
      					<!-- To skip all the exceptions -->
      					<include class="java.lang.Exception"/>
      					<include class="java.lang.Throwable"/>							 	
      				</no-rollback-exception-classes>
      			</tasklet>
      		</step>
      		<step id="step4" next="step5">
      			<tasklet>
      				<chunk reader="extractReader" writer="extractWriter" processor="extractProcessor" commit-interval="1" skip-limit="10" >
      					<skippable-exception-classes>
      						<!-- To skip all the exceptions -->
      						<include class="java.lang.Exception"/>	
      						<include class="java.lang.Throwable"/>		
      						<include class="org.springframework.batch.item.file.FlatFileParseException"/>		 	
      					</skippable-exception-classes>					
      				</chunk>
      				<no-rollback-exception-classes>
      					<!-- To skip all the exceptions -->
      					<include class="java.lang.Exception"/>
      					<include class="java.lang.Throwable"/>							 	
      				</no-rollback-exception-classes>
      				<listeners>
      					<listener ref="extractListener"/>
      				</listeners>
      			</tasklet>
      		</step>
      		<step id="step5" next="step6"> 
      			<tasklet ref="sectionPopulationCheck" />
      		</step>
      		<step id="step6" next="step7">
      			<tasklet> 
      				<chunk reader="registerReader" writer="registerWriter" processor="preRegisterProcessor" commit-interval="1" skip-limit="10">
      					<skippable-exception-classes>
      						<!-- To skip all the exceptions -->
      						<include class="java.lang.Exception"/>
      						<include class="java.lang.Throwable"/>							 	
      					</skippable-exception-classes>
      				</chunk>
      				<no-rollback-exception-classes>
      					<!-- To skip all the exceptions -->
      					<include class="java.lang.Exception"/>
      					<include class="java.lang.Throwable"/>							 	
      				</no-rollback-exception-classes>
      			</tasklet>
      		</step>
      		<step id="step7" next="step8">
      			<tasklet>
      				<chunk reader="registerReader" writer="registerWriter" processor="registerProcessor" commit-interval="1" skip-limit="10">
      					<skippable-exception-classes>
      						<!-- To skip all the exceptions -->
      						<include class="java.lang.Exception"/>
      						<include class="java.lang.Throwable"/>							 	
      					</skippable-exception-classes>					
      				</chunk>
      				<no-rollback-exception-classes>
      					<!-- To skip all the exceptions -->
      					<include class="java.lang.Exception"/>
      					<include class="java.lang.Throwable"/>							 	
      				</no-rollback-exception-classes>
      			</tasklet>
      		</step>
      		<step id="step8" next="step9">
      			<tasklet ref="clearTemplateChangeTasklet"/>
      		</step>
      		<step id="step9">
      			<tasklet ref="reportTasklet"/>
      		</step>
      	</job>
      Last edited by mminella; Nov 27th, 2012, 12:55 PM. Reason: Formatting...

      Comment

      Working...
      X