Results 1 to 5 of 5

Thread: RollBack when we throw a custom exception

  1. #1

    Default RollBack when we throw a custom exception

    Hi,

    I'm using Spring Batch 1.1.0.

    I'm using listeners to log the exception. My problem is the transaction is getting rolled back when exception is thrown by the process, but transaction is not rolled back when we manually throw a custom exception.

    Why its behaving like this ?

    Please find my job configuration below

    Code:
    <bean id="agencyMergeJob" parent="simpleJob">
    		<!-- set restartable=false so that this job can be used by more than one test -->
    		<property name="restartable" value="true"  />
    		<property name="steps">
    		<list>
    		    <bean id="procbsln" parent="skipLimitStep">
    				<property name="skipLimit" value="99999"/>
    				<property name="itemReader" ref="procBslnItemReader" />
    				<property name="itemWriter" ref="statusChangeItemWriter" />
    				<property name="commitInterval" value="1" />
    				<property name="skippableExceptionClasses"	value="java.lang.Exception"/>
    				<property name="allowStartIfComplete" value="true" />
    			</bean>
    			<bean id="agencyMerge" parent="skipLimitStep">
    				<property name="skipLimit" value="99999"/>
    				<property name="itemReader" ref="hibernateItemReader" />
    				<property name="itemWriter" ref="hibernateItemWriter" />
    				<property name="commitInterval" value="1" />
    				<property name="skippableExceptionClasses"	value="java.lang.Exception"/>
    				<property name="allowStartIfComplete" value="true" />
    				<property name="listeners">
    					<list>
    						<ref bean="skipStepListener"/>
    						<ref bean="stepListener"/>
    					</list>
    				</property>
    			</bean>
    			<bean id="statusChange" parent="skipLimitStep">
    				<property name="skipLimit" value="99999"/>
    				<property name="itemReader" ref="statusItemReader" />
    				<property name="itemWriter" ref="statusChangeItemWriter" />
    				<property name="commitInterval" value="1" />
    				<property name="skippableExceptionClasses"	value="java.lang.Exception"/>
    				<property name="allowStartIfComplete" value="true" />
    				<property name="listeners">
    					<list>
    						<ref bean="skipStepListener"/>
    						<ref bean="stepListener"/>
    					</list>
    				</property>
    			</bean>		
    		</list>	
    		</property>
    	</bean>

    My custom exception extends exception
    Code:
    throw new CustomException(message,throwable);
    when i do like the above one, my transaction is not getting rolled back

    Correct me if im wrong.
    Thanks,

    Jayasimhan

  2. #2
    Join Date
    Dec 2006
    Posts
    1,061

    Default

    Is your custom exception a checked exception? If so, there was an issue we fixed in 1.1.3 related to how the framework handles checked exceptions.

  3. #3

    Default

    Quote Originally Posted by lucasward View Post
    Is your custom exception a checked exception? If so, there was an issue we fixed in 1.1.3 related to how the framework handles checked exceptions.
    Yes Lucas, my custom exception is a checked exception.
    Will upgrade my spring batch version
    Thanks,

    Jayasimhan

  4. #4

    Default

    From where i can download 1.1.3 ?


    Quote Originally Posted by jayasimhan View Post
    Yes Lucas, my custom exception is a checked exception.
    Will upgrade my spring batch version

  5. #5

    Default

    I was using org.springframework.batch.item.support.DelegatingI temReader.

    This is being removed from version2. Is there any similar class in v2 ?

    Quote Originally Posted by jayasimhan View Post
    Yes Lucas, my custom exception is a checked exception.
    Will upgrade my spring batch version

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •