title: Handling job/step exceptions with asynchronous TaskManager
body: <p>I can't find a proper way to handle spring-batch exception in asynchronous context.</p>
  <p>When I set a <code>ThreadPoolTaskManager</code> to my <code>JobLauncher</code>, the real job/step exception is not logged anymore. Instead the log will be something like:</p>
  <pre><code>org.springframework.batch.core.JobInterruptedException: Job interrupted by step execution
  at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:165)
  at ...
  </code></pre>
  <p>I tried to resolve this adding a <code>JobExecutionListener</code> like this:</p>
  <pre><code>@Override
  public void afterJob(JobExecution jobExecution) {
      List&lt;Throwable&gt; jobExceptions = jobExecution.getFailureExceptions();
      if (CollectionUtils.isNotEmpty(jobExceptions)) {
          Throwable lastJobException = jobExceptions.get(jobExceptions.size() - 1);
          LOGGER.error(&quot;Spring-Batch error at job level&quot;, lastJobException);
          String lastJobExceptionMessage = ExceptionUtils.getRootCauseMessage(lastJobException);
  
          // storing message in ExecutionContext for the batch-admin webapp
          String message = &quot;&quot;;
          if (jobExecution.getExecutionContext().get(Consts.JOB_EXECUTION_MESSAGE_KEY) != null) {
              message = jobExecution.getExecutionContext().getString(Consts.JOB_EXECUTION_MESSAGE_KEY);
          }
          message += &quot;\n&quot; + lastJobExceptionMessage;
          jobExecution.getExecutionContext().put(Consts.JOB_EXECUTION_MESSAGE_KEY, message);
      }
  
  }
  </code></pre>
  <p>But I still end with a <code>JobInterruptedException</code>.
  Is there a way to retrieve the initial cause of the interruption (might be a error in the reader/processor/writer code?</p>