Announcement Announcement Module
Collapse
No announcement yet.
Custom Exit Code and FlowExecutionException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Custom Exit Code and FlowExecutionException

    Hi, I am trying to use a custom Exit Code ("COMPLETE_WITH_WARN") to control the steps (terminate job) I run in my job, but I get a FlowExecutionException. Any idea what have I done wrong?

    I am using SpringBatch-2.1.1-RELEASE.

    Here is how the code looks like:

    xml (step in restartable job):
    Code:
    <step
    			id="processDomainObject">
    			<tasklet>
    				<chunk
    					reader="itemreader"
    					processor="itemprocessor"
    					writer="itemwriter"
    					commit-interval="1"
    					skip-limit="1">
    					<skippable-exception-classes>
    							<include
    						class="a.b.ExceptionToSkip" />
    					</skippable-exception-classes>
    				</chunk>
    				<listeners>
    					<listener
    						ref="aSkipListener" />
    				</listeners>
    			</tasklet>
    			<next
    				on="COMPLETED"
    				to="wrapUp" />
    			<fail
    				on="COMPLETED_WITH_WARN" />
    		</step>
    aSkipListener.java:
    Code:
     public ExitStatus afterStep( StepExecution stepExecution )
        {
            ExitStatus exitStatus = stepExecution.getExitStatus();
            if ( exitStatus.equals( ExitStatus.COMPLETED ) && stepExecution.getSkipCount() > 0 )
            {
             
                return new ExitStatus("COMPLETED_WITH_WARN");
            }
            else
            {
                return exitStatus;
            }
        }

    And the exception is:

    Code:
    Caused by: org.springframework.batch.core.job.flow.FlowExecutionException: Next state not found in flow=doStuffStep for state=doStuffStep .processDomainObject with exit status=COMPLETED_WITH_WARN
    	at org.springframework.batch.core.job.flow.support.SimpleFlow.nextState(SimpleFlow.java:195)
    	at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:158)

  • #2
    You don't have anywhere for the step to go if the exit status is not one of COMPLETED or COMPLETED_WITH_WARN, so that might be a problem. But it looks like it should work in the case that is failing. Can you distil the problem down to a simple test case?

    Comment

    Working...
    X