title: Spring batch - stop job running in different JRE
body: <h2>Background:</h2>
  
  <p>I created a Stop Job which finds running jobs with the specified name as this: </p>
  
  <pre><code>jobExplorer.findRunningJobExecutions("job_A")
  </code></pre>
  
  <p>and then, for each execution of job_A it calls:</p>
  
  <pre><code>jobOperator.stop(execution.getId());
  </code></pre>
  
  <h2>Issue</h2>
  
  <p>when i call the above <code>stop()</code> method; even though it eventually accomplishes what i want, but it still throws an exception:</p>
  
  <pre><code>    WARN o.s.b.c.l.s.SimpleJobOperator [main] Cannot find Job object
  org.springframework.batch.core.launch.NoSuchJobException: No job configuration with the name [job_A] was registered
      at org.springframework.batch.core.configuration.support.MapJobRegistry.getJob(MapJobRegistry.java:66) ~[spring-batch-core-3.0.6.RELEASE.jar:3.0.6.RELEASE]
      at org.springframework.batch.core.launch.support.SimpleJobOperator.stop(SimpleJobOperator.java:403) [spring-batch-core-3.0.6.RELEASE.jar:3.0.6.RELEASE]
  </code></pre>
  
  <h2>The Cause</h2>
  
  <p>This happens when the <code>stop()</code> method tries to located job_A in the    <code>JobRegistry</code>. </p>
  
  <p>So even though job_A was found in the "<code>JobRepository</code>" because the repository looks in the database, it was not found in the "<code>JobRegistry</code>" which is a local cache of job beans created within its runtime environment, since job_A is running withing a different runtime instance it was not registered and threw and error.</p>
  
  <h2>Concern</h2>
  
  <p>Even though job 'A' stops i am still concerned what i have missed because of the exception.</p>
  
  <p>I have searched this issue and found only general answers on how to stop a job, however i did not find anyone explaining how to stop a running job of another runtime. </p>
  
  <p>Any answers would be greatly appreciated. </p>