title: SPRING-BATCH ERROR: No context holder available for step scope when using threadPoolExecutor in spring batch application
body: <p>I am currently trying to read data from .dat file and persist it into database using spring batch. I have used threading method with step scope to improve my performance but it seems that spring is unable to create proxy bean for my method. I am getting java.lang.IllegalStateException: No context holder available for step scope error. I have referenced many questions and references but none seems to address my issue. Please provide me some useful reference or any hints to my problem. Thanks in advance...</p>
  
  <p>MyConfiguration.java</p>
  
  <pre><code>@Configuration
  public class MyBatchConfiguration 
  {
      @Autowired
      JobBuilderFactory jobBuilderFactory;
  
      @Autowired
      StepBuilderFactory stepBuilderFactory;
  
      @Bean(name="commonJobCompletionListener")
      public JobCompletionNotificationListener jobCompletionlistener() 
      {
          return new JobCompletionNotificationListener();
      }
  
      @Bean(name="commonTaskExecutor")
      @Scope(value="step", proxyMode = ScopedProxyMode.TARGET_CLASS)
      public ThreadPoolTaskExecutor taskExecutor() 
      {
          ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
          executor.setCorePoolSize(3);
          executor.setMaxPoolSize(5);
          return executor;
      }
  
      @Bean(name="cstarU2NavReader")
      @Scope(value="step", proxyMode = ScopedProxyMode.TARGET_CLASS)
      public FlatFileItemReader&lt;CSTARU2NAVInputMapperDTO&gt; reader(@Value("#{jobParameters['fileName']}") String fileName) throws IOException 
      {
          FlatFileItemReader&lt;CSTARU2NAVInputMapperDTO&gt; newBean = new FlatFileItemReader&lt;&gt;();
          newBean.setName("fileReader");
          newBean.setResource(new InputStreamResource(FileUtils.openInputStream(new File(fileName))));
          newBean.setLineMapper(lineMapper());
          newBean.setLinesToSkip(1);
          return newBean;
      }
  
      @Bean(name="cstarU2NavLineMapper")
      public DefaultLineMapper&lt;CSTARU2NAVInputMapperDTO&gt; lineMapper() 
      {
          DefaultLineMapper&lt;CSTARU2NAVInputMapperDTO&gt; lineMapper = new DefaultLineMapper&lt;&gt;();
          lineMapper.setLineTokenizer(lineTokenizer());
          CSTARU2NAVReader cstarU2NavReader = new CSTARU2NAVReader();
          lineMapper.setFieldSetMapper(cstarU2NavReader);
          return lineMapper;
      }
  
      @Bean(name="cstarU2NavTokenizer")
      public DelimitedLineTokenizer lineTokenizer() 
      {
          DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
          tokenizer.setDelimiter("|");
          tokenizer.setNames("field1","field12","field13","field14");
          tokenizer.setIncludedFields(0,2,3,5);
          return tokenizer;
      }
  
      @Bean(name="cstarU2NavBatchProcessor")
      public ItemProcessor&lt;CSTARU2NAVInputMapperDTO, IntReplNav&gt; processor() 
      {
          return new CSTARU2NAVProcessor();
      }
  
      @Bean(name="cstarU2NavBatchWriter")
      public ItemWriter&lt;IntReplNav&gt; writer() 
      {
          return new CSTARU2NAVWriter();
      }
  
      @Bean(name="cstarU2NavStep")
      public Step step1() throws IOException 
      {
          return stepBuilderFactory.get("cstarU2NavStep")
                  .&lt;CSTARU2NAVInputMapperDTO, IntReplNav&gt;chunk(10)
                  .reader(this.reader(null))
                  .processor(this.processor())
                  .writer(this.writer())
                  .taskExecutor(this.taskExecutor())
                  .build();
      }
  
      @Bean(name="cstarU2NavFileImportJob")
      public Job importUserJob(@Autowired @Qualifier("cstarU2NavStep") Step step1) 
      {
          return jobBuilderFactory
                  .get("cstarU2NavFileImportJob"+new Date())
                  .incrementer(new RunIdIncrementer())
                  .listener(this.jobCompletionlistener())
                  .flow(step1)
                  .end()
                  .build();
      }
  
  }
  </code></pre>
  
  <p>JobCompletionNotificationListener.java</p>
  
  <pre><code>public class JobCompletionNotificationListener extends JobExecutionListenerSupport
  {
  
      @Autowired
      ThreadPoolTaskExecutor taskExecutor; 
  
      @Override
      public void afterJob(JobExecution jobExecution) 
      {
          if(jobExecution.getStatus() == BatchStatus.COMPLETED) 
          {
              taskExecutor.shutdown();
          }
      }
  
  }
  
  </code></pre>
  
  <p>ErrorLog</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.commonTaskExecutor': Scope 'step' 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 step scope
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:362) ~[spring-beans-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:35) ~[spring-aop-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:672) ~[spring-aop-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor$$EnhancerBySpringCGLIB$$621affe0.shutdown(&lt;generated&gt;) ~[spring-context-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at com.capgroup.horizon.pricecapture.listener.JobCompletionNotificationListener.afterJob(JobCompletionNotificationListener.java:20) ~[classes/:?]
      at org.springframework.batch.core.listener.CompositeJobExecutionListener.afterJob(CompositeJobExecutionListener.java:60) ~[spring-batch-core-4.0.2.RELEASE.jar:4.0.2.RELEASE]
      at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:354) ~[spring-batch-core-4.0.2.RELEASE.jar:4.0.2.RELEASE]
      at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:144) ~[spring-batch-core-4.0.2.RELEASE.jar:4.0.2.RELEASE]
      at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50) ~[spring-core-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:137) ~[spring-batch-core-4.0.2.RELEASE.jar:4.0.2.RELEASE]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_144]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_144]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_144]
      at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_144]
      at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) ~[spring-aop-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:197) ~[spring-aop-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$PassthruAdvice.invoke(SimpleBatchConfiguration.java:127) ~[spring-batch-core-4.0.2.RELEASE.jar:4.0.2.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) ~[spring-aop-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at com.sun.proxy.$Proxy122.run(Unknown Source) ~[?:?]
      at com.capgroup.horizon.pricecapture.services.impl.CSTARU2NAVFileServiceImpl.process(CSTARU2NAVFileServiceImpl.java:34) ~[classes/:?]
      at com.capgroup.horizon.pricecapture.services.impl.CSTARU2NAVFileServiceImpl$$FastClassBySpringCGLIB$$b9bdc800.invoke(&lt;generated&gt;) ~[classes/:?]
      at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:746) ~[spring-aop-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) ~[javamelody-core-1.74.0.jar:1.74.0]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688) ~[spring-aop-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at com.capgroup.horizon.pricecapture.services.impl.CSTARU2NAVFileServiceImpl$$EnhancerBySpringCGLIB$$76b5d896.process(&lt;generated&gt;) ~[classes/:?]
      at com.capgroup.horizon.pricecapture.services.impl.FileProcessServiceImpl.processFile(FileProcessServiceImpl.java:71) ~[classes/:?]
      at com.capgroup.horizon.pricecapture.services.impl.FileProcessServiceImpl.execute(FileProcessServiceImpl.java:56) ~[classes/:?]
      at com.capgroup.horizon.pricecapture.services.impl.FileProcessServiceImpl$$FastClassBySpringCGLIB$$6a723fea.invoke(&lt;generated&gt;) ~[classes/:?]
      at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:746) ~[spring-aop-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) ~[javamelody-core-1.74.0.jar:1.74.0]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688) ~[spring-aop-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at com.capgroup.horizon.pricecapture.services.impl.FileProcessServiceImpl$$EnhancerBySpringCGLIB$$d2008294.execute(&lt;generated&gt;) ~[classes/:?]
      at com.capgroup.horizon.pricecapture.controllers.BatchController.fileProcess(BatchController.java:36) ~[classes/:?]
      at com.capgroup.horizon.pricecapture.controllers.BatchController$$FastClassBySpringCGLIB$$50364d5.invoke(&lt;generated&gt;) ~[classes/:?]
      at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:746) ~[spring-aop-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) ~[javamelody-core-1.74.0.jar:1.74.0]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688) ~[spring-aop-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at com.capgroup.horizon.pricecapture.controllers.BatchController$$EnhancerBySpringCGLIB$$2350dc35.fileProcess(&lt;generated&gt;) ~[classes/:?]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_144]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_144]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_144]
      at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_144]
      at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209) ~[spring-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) ~[spring-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102) ~[spring-webmvc-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:891) ~[spring-webmvc-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797) ~[spring-webmvc-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991) ~[spring-webmvc-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925) ~[spring-webmvc-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:981) ~[spring-webmvc-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:873) ~[spring-webmvc-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:858) ~[spring-webmvc-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-embed-websocket-8.5.37.jar:8.5.37]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at org.zalando.logbook.servlet.NormalStrategy.doFilter(NormalStrategy.java:38) ~[logbook-servlet-1.12.1.jar:?]
      at org.zalando.logbook.servlet.LogbookFilter.doFilter(LogbookFilter.java:39) ~[logbook-servlet-1.12.1.jar:?]
      at org.zalando.logbook.servlet.HttpFilter.doFilter(HttpFilter.java:31) ~[logbook-servlet-1.12.1.jar:?]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) ~[javamelody-core-1.74.0.jar:1.74.0]
      at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) ~[javamelody-core-1.74.0.jar:1.74.0]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109) ~[spring-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) ~[spring-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) ~[spring-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[?:1.8.0_144]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[?:1.8.0_144]
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-8.5.37.jar:8.5.37]
      at java.lang.Thread.run(Thread.java:748) [?:1.8.0_144]
  Caused by: java.lang.IllegalStateException: No context holder available for step scope
      at org.springframework.batch.core.scope.StepScope.getContext(StepScope.java:167) ~[spring-batch-core-4.0.2.RELEASE.jar:4.0.2.RELEASE]
      at org.springframework.batch.core.scope.StepScope.get(StepScope.java:99) ~[spring-batch-core-4.0.2.RELEASE.jar:4.0.2.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:350) ~[spring-beans-5.0.12.RELEASE.jar:5.0.12.RELEASE]
      ... 112 more
  </code></pre>
  
  <p>Link for sample project to reproduce the above issue : <a href="https://github.com/Anand450623/Spring-Batch" rel="nofollow noreferrer">https://github.com/Anand450623/Spring-Batch</a></p>