Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6724243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:39:56+00:00 2026-05-26T09:39:56+00:00

The issue is this: I have a Spring Batch job with a single step.

  • 0

The issue is this: I have a Spring Batch job with a single step. This step is called multiple times. If every time it’s called everything works ok (no Exceptions) the Job status is “COMPLETED”. If something bad happends at least in one of the executions of the Step (an exception is thrown) I’ve configured a StepListener that changes the exit code to FAILED:

public class SkipCheckingListener extends StepExecutionListenerSupport {

    public ExitStatus afterStep(StepExecution stepExecution) {
        String exitCode = stepExecution.getExitStatus().getExitCode();
        if (stepExecution.getProcessorSkipCount() > 0) {
            return new ExitStatus(ExitStatus.FAILED);
        }
        else {
            return null;
        }
    }

}

This works fine, when the condition is met the “if” block is exectued and the job finishes with status FAILED. Notice however that the exit code I return here is still amongst the standard ones that come with Spring Batch. I would like to return my personalized exit code such as “COMPLETED WITH SKIPS” at certain points. Now I’ve tried updating the above code to return just that:

public class SkipCheckingListener extends StepExecutionListenerSupport {

    public ExitStatus afterStep(StepExecution stepExecution) {
        String exitCode = stepExecution.getExitStatus().getExitCode();
        if (stepExecution.getProcessorSkipCount() > 0) {
            return new ExitStatus("COMPLETED WITH SKIPS");
        }
        else {
            return null;
        }
    }

}

as it is described in the docs: http://static.springsource.org/spring-batch/reference/html/configureStep.html (5.3.2.1. Batch Status vs. Exit Status). I’ve even tried

stepExecution.getJobExecution().setExitStatus("COMPLETED WITH SKIPS");

And sure enough, the execution arrives in the “if” block, executes the code, and still my job finishes with exit code COMPLETED, completly ignoring the exit code I’ve set via the listener.

There’s no more details on this in their docs, and I haven’t found anything using Google. Can someone plz tell me how do I go about changing the Job exit code in this fashion? Thanx

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:39:57+00:00Added an answer on May 26, 2026 at 9:39 am

    looks like you just can’t alter the BatchStatus, but you can try it with the exitstatus

    this code with a JobListener works for me

    // JobListener with interface or annotation
    public void afterJob(JobExecution jobExecution) {
        jobExecution.setExitStatus(new ExitStatus("foo", "fooBar"));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

can you please help me with this issue the String class does not have
I have this issue with ComboBox that uses IEnumerable<Brush> as ItemsSource; the problem lies
I do not currently have this issue , but you never know, and thought
I have this strange issue with my web app. You see, I'm using jQuery
I have this exact issue ASP.net can’t update page from event handler and it's
I have this chronic issue with iPhone UI development where views sometimes seem to
Ok so I've spent a couple hours trying to resolve this issue and have
Continuing my problem from yesterday, the Silverlight datagrid I have from this issue is
I am having trouble with the following SQL statement. I have had this issue
Note: This issue appears to be limited to SQL Server 2005 SP2 I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.