title: How to forcefully stop a job in Spring Batch?
body: <p>I have a web application that creates jobs periodically. This web app is on a server and works fine. If the server crashes and then restarts, the <code>JobExplorer</code> shows that job is still running. But in fact that job never stops and I have to stop it myself. To do so, I am trying to use the <code>JobOperator</code> and the funny thing is it says it cannot stop a job that is not running.  </p>
  
  <p>To get a list of running jobs:</p>
  
  <pre><code>for (String jn : jobExplorer.getJobNames())             
     for (JobExecution je : jobExplorer.findRunningJobExecutions(jn)) {
          ...
      }
  </code></pre>
  
  <p>To stop a job:</p>
  
  <pre><code>try {
      jobOperator.stop(je.getId());
  } catch (NoSuchJobExecutionException e1) {
      e1.printStackTrace();
  } catch (JobExecutionNotRunningException e1) {
      e1.printStackTrace();
  }
  </code></pre>
  
  <p>The error message is "JobExecution must be running so that it can be stopped"</p>
  
  <p>Both <code>je.isRunning()</code> and <code>je.isStopping()</code> return true.</p>