title: Properties file load to replace value in spring batch XML
body: <p>Since a day i'm working on an issue. To make my code easier to maintain, I want to set all the constant i need in Spring Batch in a propertie file (My_Project/src/main/resources/spring/batch/config/batch.properties).</p>
  
  <p>I search on the web several example ans nothing works. For this I replace my constant by ${constantNameInPorpertiesFile}</p>
  
  <p>My context.xml
  My_Project/src/main/resources/spring/batch/config/context.xml</p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:context="http://www.springframework.org/schema/context"
  xsi:schemaLocation="
      http://www.springframework.org/schema/beans 
      http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
      http://www.springframework.org/schema/context 
      http://www.springframework.org/schema/context/spring-context-3.2.xsd"&gt;
  
   &lt;!-- stored job-meta in memory--&gt;
      &lt;bean id="jobRepository"
      class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean"&gt;
          &lt;property name="transactionManager" ref="transactionManager"/&gt;
      &lt;/bean&gt;
  
      &lt;bean id="transactionManager"
      class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" /&gt;
  
      &lt;bean id="jobLauncher"
      class="org.springframework.batch.core.launch.support.SimpleJobLauncher"&gt;
          &lt;property name="jobRepository" ref="jobRepository" /&gt;
      &lt;/bean&gt;
      &lt;context:property-placeholder location="classpath:spring/batch/config/batch.properties"/&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>In this context.xml I expect that
   "" will replace my constant in the will which import the context.xml.</p>
  
  <p>For example this spring batch file (My_Project/src/main/resources/spring/batch/jobs/CreateSpecificationFileJob.xml):</p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:batch="http://www.springframework.org/schema/batch" xmlns:context="http://www.springframework.org/schema/context"
  
  xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
      http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.2.xsd
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
      http://www.springframework.org/schema/context 
      http://www.springframework.org/schema/context/spring-context-3.2.xsd"&gt;
  
  &lt;context:property-placeholder location="classpath:spring/batch/config/batch.properties"/&gt;
  
  &lt;import resource="../config/context.xml"/&gt;  
  
  &lt;!-- Flow for the V4 specification file creation --&gt;
  &lt;flow id="createSpecificationFileFlow" xmlns="http://www.springframework.org/schema/batch"&gt;
  
      &lt;step id="formRecognitionPartitionerStep"&gt;
          &lt;partition partitioner="formRecognitionPartitioner"&gt;
              &lt;handler grid-size="1" task-executor="syncTaskExecutor" /&gt;
              &lt;!-- partitioner will run this job, with different stepExecutionContext values.      --&gt;
              &lt;step&gt;
                  &lt;flow parent="createAndCompleteSpecificationFile"/&gt;
              &lt;/step&gt;
          &lt;/partition&gt;
      &lt;/step&gt;
  &lt;/flow&gt;
  
  &lt;!-- sub-Flow to make all process on each form --&gt;  
  &lt;flow id="createAndCompleteSpecificationFile" xmlns="http://www.springframework.org/schema/batch"&gt;
      &lt;step id="createSpecificationFile" next="sheetRecognitionPartitionerStep"&gt;
          &lt;tasklet ref="createSpecificationFileTasklet"/&gt;
      &lt;/step&gt;
  
      &lt;step id="sheetRecognitionPartitionerStep"&gt;
          &lt;partition partitioner="sheetRecognitionPartitioner"&gt;
              &lt;handler grid-size="1" task-executor="syncTaskExecutor" /&gt;
              &lt;!--partitioner will run this job, with different stepExecutionContext values. --&gt;
              &lt;step&gt;
                  &lt;flow parent="completeSheet"/&gt;
              &lt;/step&gt;
          &lt;/partition&gt;
      &lt;/step&gt;
  &lt;/flow&gt;
  
  &lt;!-- sub-Flow to make all process on each sheet of a form --&gt;   
  &lt;flow id="completeSheet" xmlns="http://www.springframework.org/schema/batch"&gt;
      &lt;step id="gridRecognition" next="labelRecognition"&gt;
          &lt;tasklet ref="gridRecognitionTasklet"/&gt;
      &lt;/step&gt;
      &lt;step id="labelRecognition" next="putDataInV4SpecificationFile"&gt;
          &lt;tasklet ref="labelRecognitionTasklet"/&gt;
      &lt;/step&gt;
      &lt;step id="putDataInV4SpecificationFile" next="constantManagement"&gt;
          &lt;tasklet ref="putDataInV4SpecificationFileTasklet"/&gt;
      &lt;/step&gt;
      &lt;step id="constantManagement" next="fileHeaderAndFooter"&gt;
          &lt;tasklet ref="constantManagementTasklet"/&gt;
      &lt;/step&gt;
      &lt;step id="fileHeaderAndFooter" next="sheetLayoutForPrinting"&gt;
          &lt;tasklet ref="fileHeaderAndFooterTasklet"/&gt;
      &lt;/step&gt;
      &lt;step id="sheetLayoutForPrinting"&gt;  
          &lt;tasklet ref="sheetLayoutForPrintingTasklet"/&gt;
      &lt;/step&gt; 
  &lt;/flow&gt;
  
  
  &lt;!-- List of tasklet --&gt;
  &lt;bean id="createSpecificationFileTasklet" class="com.sopra.ner.specification.excel.write.CreateSpecificationFileTasklet" scope="step" &gt;
      &lt;property name="${partitionner.list_of_sheet}" value="#{stepExecutionContext['${partitionner.list_of_sheet}']}" /&gt;
  &lt;/bean&gt;
  &lt;bean id="gridRecognitionTasklet" class="com.sopra.ner.specification.excel.read.GridRecognitionTasklet" scope="step"&gt;
      &lt;property name="${partitionner.sheet}" value="#{stepExecutionContext['${partitionner.sheet}']}" /&gt;
  &lt;/bean&gt;
  &lt;bean id="labelRecognitionTasklet" class="com.sopra.ner.specification.excel.read.LabelRecognitionTasklet" scope="step"/&gt;
  &lt;bean id="putDataInV4SpecificationFileTasklet" class="com.sopra.ner.specification.excel.write.PutDataInV4SpecificationFileTasklet" scope="step"/&gt;
  &lt;bean id="constantManagementTasklet" class="com.sopra.ner.specification.excel.write.ConstantManagementTasklet" scope="step"/&gt;
  &lt;bean id="fileHeaderAndFooterTasklet" class="com.sopra.ner.specification.excel.write.FileHeaderAndFooterTasklet" scope="step"/&gt;
  &lt;bean id="sheetLayoutForPrintingTasklet" class="com.sopra.ner.specification.excel.write.SheetLayoutForPrintingTasklet" scope="step"/&gt;
  
  &lt;bean id="syncTaskExecutor" class="org.springframework.core.task.SyncTaskExecutor"/&gt;
  
  &lt;!-- List of partition --&gt;
  &lt;bean id="formRecognitionPartitioner" class="com.sopra.ner.specification.excel.FormRecognitionPartitioner" scope="step"/&gt;
  &lt;bean id="sheetRecognitionPartitioner" class="com.sopra.ner.specification.excel.SheetRecognitionPartitioner" scope="step"&gt;
      &lt;property name="${partitionner.list_of_sheet}" value="#{jobExecutionContext['${partitionner.list_of_sheet}']}" /&gt;
  &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>This flow is launch by a job. Without any constant.
  The error is: 
  - Invalid property '${partitionner.list_of_sheet}' of bean class        [com.sopra.ner.specification.excel.write.CreateSpecificationFileTasklet] ................</p>
  
  <p>When i open the file in target folder, the value is not replace.</p>
  
  <p>If you have any idea to solve this i will be grateful. </p>