title: Spring Batch 3.0.10 - Parallel Steps using TaskExecutor - Does not understand Job scope beans
body: <p>There seem to be a lot of questions around this subject, but I can't seem to find the answer.  Sorry if this is a dupe!</p>
  <p>I have a Job that has many steps...at one point I want to run the item processing (read/validate/write) of multiple files in parallel.  Before making this code parallel, I ran it synchronously and everything was fine.  When I add the batch:split using task-executor, I now get the error:</p>
  <p>2020-09-01 01:07:12,668 [SimpleAsyncTaskExecutor-1] ERROR AbstractStep - Encountered an error executing step loadBaseFareInfo in job ATPRuleCombined
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.allAddsCleanupProcessorForBaseFareInfo': Scope 'job' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No context holder available for job scope</p>
  <p>Here is the relevant code:</p>
  <pre><code>        &lt;batch:split id=&quot;loadMainTables&quot; next=&quot;saveCacheNotification&quot; task-executor=&quot;taskExecutor&quot;&gt;
          &lt;batch:flow&gt;
              &lt;batch:step id=&quot;loadBaseFareInfo&quot;&gt;
                  &lt;batch:tasklet&gt;
                      &lt;batch:chunk reader=&quot;baseFareInfoGroupReader&quot; processor=&quot;baseFareInfoGroupValidator&quot;  writer=&quot;baseFareInfoGroupWriter&quot;
                                   chunk-completion-policy=&quot;baseFareInfoCompletionPolicy&quot;&gt;
                          &lt;!--commit-interval=&quot;${baseFareInfo.commitInterval}&quot;&gt; --&gt;
                          &lt;!-- skip-policy=&quot;alwaysSkipPolicy&quot;&gt; --&gt;
                          &lt;batch:listeners&gt;
                              &lt;batch:listener ref=&quot;errorDataFileItemReadListener&quot;/&gt;
                              &lt;batch:listener ref=&quot;springContextRepo&quot;/&gt;
                              &lt;batch:listener ref=&quot;allAddsCleanupProcessorForBaseFareInfo&quot;/&gt;
                              &lt;batch:listener ref=&quot;baseFareInfo.groupMetricListener&quot;/&gt;
                              &lt;batch:listener ref=&quot;baseFareInfoGroupWriter&quot;/&gt;
                              &lt;batch:listener ref=&quot;baseFareInfoGroupReader&quot;/&gt;
                              &lt;batch:listener ref=&quot;baseFareInfoStepLocking&quot;/&gt;
                          &lt;/batch:listeners&gt;
                          &lt;batch:streams&gt;
                              &lt;batch:stream ref=&quot;baseFareInfoItemReader&quot;/&gt;
                          &lt;/batch:streams&gt;
                      &lt;/batch:chunk&gt;
                  &lt;/batch:tasklet&gt;
              &lt;/batch:step&gt;
          &lt;/batch:flow&gt;
          &lt;batch:flow&gt;
              &lt;batch:step id=&quot;loadNegFareSecurity&quot;&gt;
                  &lt;batch:tasklet&gt;
                      &lt;batch:chunk reader=&quot;negFareSecurityGroupReader&quot; processor=&quot;negFareSecurityGroupValidator&quot;  writer=&quot;negFareSecurityGroupWriter&quot;
                                   chunk-completion-policy=&quot;negFareSecurityCompletionPolicy&quot;&gt;
                          &lt;!--commit-interval=&quot;${negFareSecurity.commitInterval}&quot;&gt; --&gt;
                          &lt;!-- skip-policy=&quot;alwaysSkipPolicy&quot;&gt; --&gt;
                          &lt;batch:listeners&gt;
                              &lt;batch:listener ref=&quot;errorDataFileItemReadListener&quot;/&gt;
                              &lt;batch:listener ref=&quot;springContextRepo&quot;/&gt;
                              &lt;batch:listener ref=&quot;allAddsCleanupProcessorForNegFareSecurity&quot;/&gt;
                              &lt;batch:listener ref=&quot;negFareSecurity.groupMetricListener&quot;/&gt;
                              &lt;batch:listener ref=&quot;negFareSecurityGroupWriter&quot;/&gt;
                              &lt;batch:listener ref=&quot;negFareSecurityGroupReader&quot;/&gt;
                              &lt;batch:listener ref=&quot;negFareSecurityStepLocking&quot;/&gt;
                          &lt;/batch:listeners&gt;
                          &lt;batch:streams&gt;
                              &lt;batch:stream ref=&quot;negFareSecurityItemReader&quot;/&gt;
                          &lt;/batch:streams&gt;
                      &lt;/batch:chunk&gt;
                  &lt;/batch:tasklet&gt;
              &lt;/batch:step&gt;
          &lt;/batch:flow&gt;
      &lt;/batch:split&gt;
  
      &lt;bean id=&quot;allAddsCleanupProcessorForBaseFareInfo&quot;
        class=&quot;com.sabre.aircontent.batch2.rule.basefareinfo.cleanup.AllAddsCleanupProcessorForBaseFareInfo&quot; scope=&quot;job&quot;&gt;
      &lt;property name=&quot;headerRepo&quot; ref=&quot;headerRepo&quot; /&gt;
      &lt;property name=&quot;allAddsCleanupCursor&quot; ref=&quot;hibernateCursorForBaseFareInfoAllAddsCleanup&quot; /&gt;
      &lt;property name=&quot;dao&quot; ref=&quot;baseFareInfoDao&quot; /&gt;
      &lt;property name=&quot;cacheNotificationService&quot; ref=&quot;cacheNotificationService&quot;/&gt;
      &lt;property name=&quot;resourceName&quot; value=&quot;#{jobParameters['job.resource']}&quot; /&gt;
      &lt;property name=&quot;entityName&quot; value=&quot;${baseFareInfo.baseEntityName:#{null}}&quot; /&gt;
      &lt;property name=&quot;expireThresholdInPercent&quot; value=&quot;${basefareinfo.allAdds.expireThresholdInPercent}&quot;/&gt;
      &lt;property name=&quot;metricRepo&quot; ref=&quot;baseFareInfo.metricRepo&quot;/&gt;
      &lt;property name=&quot;jobStartTime&quot;
                value=&quot;#{jobExplorer.getJobExecution(jobOperator.getExecutions(jobExecution.jobInstance.instanceId)[jobOperator.getExecutions(jobExecution.jobInstance.instanceId).size()-1]).startTime}&quot;/&gt;
      &lt;property name=&quot;additionalCursorParamValues&quot;&gt;
          &lt;map&gt;
              &lt;entry key=&quot;vendor&quot; value=&quot;${vendor}&quot; /&gt;
          &lt;/map&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  <p>Why is the job scope of the allAddsCleanupProcessorForBaseFareInfo bean not recognized anymore?  Is their a workaround to this?</p>