Announcement Announcement Module
Collapse
No announcement yet.
Job status is COMPLETED even after exception is thrown Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Job status is COMPLETED even after exception is thrown

    Hi,

    As of now, my job is configured to <batch:end on="FAILED"/> for step 1 and hence it completes with status COMPLETED if any exception occurs.

    I would like the job to end with FAILED status so that it can be restarted? should I remove <batch:end on="FAILED"/> and will it stop automatically after first failure and not move to next step?


    Code:
    Caused by: java.lang.IllegalStateException: Input resource must exist (reader is in 'strict' mode): URL [file:/C:/test.txt]
    	at org.springframework.batch.item.file.FlatFileItemReader.doOpen(FlatFileItemReader.java:250)
    	at org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.open(AbstractItemCountingItemStreamItemReader.java:134)
    	... 26 more
    
    [SimpleAsyncTaskExecutor-2] ERROR org.springframework.batch.core.step.AbstractStep - Exception in afterStep callback
    java.lang.IllegalArgumentException: No records were loaded!
    	at org.springframework.util.Assert.isTrue(Assert.java:65)
    	at org.springframework.batch.core.listener.step.GenericStepExecutionListener.afterStep(GenericStepExecutionListener.java:37)
    	at org.springframework.batch.core.listener.CompositeStepExecutionListener.afterStep(CompositeStepExecutionListener.java:62)
    	at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:223)
    	at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:135)
    [SimpleAsyncTaskExecutor-2] INFO  org.springframework.batch.core.launch.support.SimpleJobLauncher - Job: [FlowJob: [name=loadFile]] completed with the following parameters: [{output.file=file:/C:/test503.TXT, input.file=file:/C:/test.TXT}] and the following status: [COMPLETED]

  • #2
    I would like the job to end with FAILED status so that it can be restarted? should I remove <batch:end on="FAILED"/> and will it stop automatically after first failure and not move to next step?
    yes. Any exception thrown in a step fails the step execution and then Spring Batch fails the job execution (this is the default).

    Comment


    • #3
      Yes. It does that's what I meant when I said the batch status is set to COMPLETED. COMPLETED jobs cannot be restarted.

      Looking for answers to my question (while I try to figure out...)?

      Originally posted by arno View Post
      yes. Any exception thrown in a step fails the step execution and then Spring Batch fails the job execution (this is the default).

      Comment


      • #4
        sorry if my previous answer wasn't clear enough (or if I don't get your question): if you remove <batch:end on="FAILED"/>, the job execution would have a FAILED status when an exception is thrown in the first step and you'll be able to restart the corresponding instance.

        Comment

        Working...
        X