title: Spring Batch partitioned step not running
body: <p>I was trying to configure my first multi-threaded job. We have a master file of about 200,000 records which we need to process. I want to break the file down into 10 files and process them. The split file tasklet is working fine &amp; it splits the bug file into 10 smaller files. I am passing the path of the files to the job in the job parameters key as &quot;urlFilesPath&quot; and value as&quot;file:/<strong>scraper</strong> /spliturl*&quot;. I verified that the files are being read correctly in the <strong>MultiResourcePartitioner</strong> bean.</p>
  <p>The master step is running in my configuration but the slave step does not run. Below is my configuration.</p>
  <p><strong>Partitioner:</strong></p>
  <pre><code>&lt;bean id=&quot;partitioner&quot;
      class=&quot;org.springframework.batch.core.partition.support.MultiResourcePartitioner&quot;
      scope=&quot;step&quot;&gt;
      &lt;property name=&quot;resources&quot; value=&quot;#{jobParameters['urlFilesPath']}&quot; /&gt;
  &lt;/bean&gt;
  </code></pre>
  <p><strong>MultiResourceItemReader:</strong></p>
  <pre><code>&lt;bean id=&quot;multiResourceItemReader&quot;
      class=&quot;org.springframework.batch.item.file.MultiResourceItemReader&quot;
      scope=&quot;step&quot;&gt;
      &lt;property name=&quot;resources&quot; value=&quot;#{jobParameters['urlFilesPath']}&quot; /&gt;
      &lt;property name=&quot;delegate&quot; ref=&quot;urlFileItemReader&quot; /&gt;
      &lt;property name=&quot;strict&quot; value=&quot;true&quot; /&gt;
      &lt;property name=&quot;saveState&quot; value=&quot;false&quot; /&gt;
  &lt;/bean&gt;
  </code></pre>
  <p><strong>FlatFileItemWriter:</strong></p>
  <pre><code>&lt;bean id=&quot;urlFileItemReader&quot; class=&quot;org.springframework.batch.item.file.FlatFileItemReader&quot;
  scope=&quot;step&quot;&gt;
      &lt;property name=&quot;lineMapper&quot; ref=&quot;passThroughLineMapper&quot; /&gt;      
      &lt;property name=&quot;resource&quot; value=&quot;#{stepExecutionContext['fileName']}&quot; /&gt; 
      &lt;property name=&quot;saveState&quot; value=&quot;true&quot; /&gt; 
  &lt;/bean&gt;
  </code></pre>
  <p><strong>Job Configuration:</strong></p>
  <pre><code>&lt;batch:job id=&quot;importJob&quot; job-repository=&quot;jobRepository&quot;&gt;
      &lt;batch:step id=&quot;fileSplitter&quot; next=&quot;readURLFileRunner&quot;&gt;
          &lt;batch:tasklet ref=&quot;fileSplittingTasklet&quot;
              transaction-manager=&quot;transactionManager&quot; /&gt;
      &lt;/batch:step&gt;
  
      &lt;batch:step id=&quot;readURLFileRunner&quot;&gt;
          &lt;batch:partition step=&quot;readURLFile&quot; partitioner=&quot;partitioner&quot;&gt;
              &lt;batch:handler grid-size=&quot;10&quot; task-executor=&quot;taskExecutor&quot; /&gt;
          &lt;/batch:partition&gt;
      &lt;/batch:step&gt;
  &lt;/batch:job&gt;
  </code></pre>
  <p><strong>Slave Step Configuration:</strong></p>
  <pre><code>&lt;batch:step id=&quot;readURLFile&quot;&gt;
      &lt;batch:tasklet transaction-manager=&quot;transactionManager&quot;
          task-executor=&quot;taskExecutor&quot; throttle-limit=&quot;10&quot;&gt;
          &lt;batch:chunk reader=&quot;multiResourceItemReader&quot; processor=&quot;urlFileItemProcessor&quot;
              writer=&quot;validURLItemWriter&quot; commit-interval=&quot;200&quot; skip-limit=&quot;100&quot;&gt;
              &lt;batch:skippable-exception-classes&gt;
                  &lt;batch:include class=&quot;java.net.MalformedURLException&quot; /&gt;
                  &lt;batch:include class=&quot;java.net.URISyntaxException&quot; /&gt;
                  &lt;batch:include class=&quot;java.net.UnknownHostException&quot; /&gt;
              &lt;/batch:skippable-exception-classes&gt;
          &lt;/batch:chunk&gt;
          &lt;batch:listeners&gt;
              &lt;batch:listener ref=&quot;malformedURLExceptionListener&quot; /&gt;
              &lt;batch:listener ref=&quot;uriSyntaxExceptionListener&quot; /&gt;
              &lt;batch:listener ref=&quot;unknownHostExceptionListener&quot; /&gt;
          &lt;/batch:listeners&gt;
      &lt;/batch:tasklet&gt;
      &lt;batch:end on=&quot;COMPLETED&quot; /&gt;
  &lt;/batch:step&gt;
  </code></pre>
  <p>Please advise what I am doing incorrectly. I do not see the processor <strong>urlFileItemProcessor</strong> &amp; the writer <strong>validURLItemWriter</strong> being executed.</p>
  <p><strong>Update</strong>
  I followed the answer given by @dimzak. But I still do not see the step <strong>readURLFile</strong> being executed and loggers from the <strong>urlFileItemProcessor</strong> &amp; <strong>validURLItemWriter</strong> are not printed to the console. The job hangs at after the following logger</p>
  <pre><code>org.springframework.batch.repeat.support.TaskExecutorRepeatTemplate - Starting repeat context.
  </code></pre>
  <p>I have doubt on the way I have configured the step scope.</p>
  <p><strong>StepScope Configuration</strong></p>
  <pre><code>&lt;bean class=&quot;org.springframework.batch.core.scope.StepScope&quot;&gt;
      &lt;property name=&quot;autoProxy&quot; value=&quot;true&quot;/&gt;
      &lt;property name=&quot;proxyTargetClass&quot; value=&quot;true&quot;/&gt;
  &lt;/bean&gt;
  </code></pre>
  <p>On the Spring forums, I have read that the <strong>delegate</strong> property of <strong>multiResourceItemReader</strong> need not be step scoped. When I removed the <strong>scope=&quot;step&quot;</strong> from the <strong>urlFileItemReader</strong>, I get the below exception.</p>
  <pre><code>    INFO : 26 Sep 2014 00:10:58,811 - org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor - Initializing ExecutorService  'taskExecutor'
  INFO : 26 Sep 2014 00:10:59,066 - org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor - Shutting down ExecutorService 'taskExecutor'
  Exception in thread &quot;main&quot; org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'urlFileItemReader' defined in class path resource [beansBatchService.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Field or property 'stepExecutionContext' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext'
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
      at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:139)
      at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:83)
      at com.chw.hma.service.batch.jobrunner.MainJobRunner.run(MainJobRunner.java:29)
      at com.chw.hma.service.batch.jobrunner.MainJobRunner.main(MainJobRunner.java:21)
  Caused by: org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Field or property 'stepExecutionContext' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext'
      at org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:146)
      at org.springframework.beans.factory.support.AbstractBeanFactory.evaluateBeanDefinitionString(AbstractBeanFactory.java:1364)
      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.evaluate(BeanDefinitionValueResolver.java:214)
      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:186)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1456)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1197)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
      ... 12 more
  Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Field or property 'stepExecutionContext' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext'
      at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:217)
      at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:85)
      at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:78)
      at org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:49)
      at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:85)
      at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:102)
      at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:94)
      at org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:143)
      ... 18 more
  </code></pre>
  <p>Please advise.</p>
  <p><strong>Update Sep 27, 2014</strong></p>
  <p>Posting the task executor etc, as advised by @dimzak</p>
  <pre><code>&lt;bean id=&quot;taskExecutor&quot;
      class=&quot;org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor&quot;&gt;
      &lt;property name=&quot;corePoolSize&quot; value=&quot;10&quot; /&gt;
      &lt;property name=&quot;maxPoolSize&quot; value=&quot;10&quot; /&gt;
  &lt;/bean&gt;
  
  &lt;bean id=&quot;jobRepository&quot;
      class=&quot;org.springframework.batch.core.repository.support.JobRepositoryFactoryBean&quot;&gt;
      &lt;property name=&quot;transactionManager&quot; ref=&quot;transactionManager&quot; /&gt;
      &lt;property name=&quot;dataSource&quot; ref=&quot;dataSource&quot; /&gt;
      &lt;property name=&quot;databaseType&quot; value=&quot;mySQL&quot; /&gt;
  &lt;/bean&gt;
  
  &lt;bean id=&quot;jobLauncher&quot;
      class=&quot;org.springframework.batch.core.launch.support.SimpleJobLauncher&quot;&gt;
      &lt;property name=&quot;jobRepository&quot; ref=&quot;jobRepository&quot; /&gt;
      &lt;property name=&quot;taskExecutor&quot; ref=&quot;taskExecutor&quot; /&gt;
  &lt;/bean&gt;
  </code></pre>