Announcement Announcement Module
Collapse
No announcement yet.
Late binding not working Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Late binding not working

    I'm using Spring 2.5.6 and Spring Batch 2.0.0.RC1.

    I'm configuring my jobs with the ClasspathXmlJobRegistry:

    Code:
    <bean id="jobLocator" class="org.springframework.batch.core.configuration.support.ClassPathXmlJobRegistry">
          <property name="jobPaths">
            <list>
              <value>classpath:spring/batch-device-processing-delayed-provisioning-prototype-beans.xml</value>
              <value>classpath:spring/batch-device-processing-immediate-provisioning-prototype-beans.xml</value>
            </list>
          </property>
        </bean>
    In the config files for the jobs, I have this configured for my job/reader:

    Code:
    <bean id="uploadReader" class="org.springframework.batch.item.file.FlatFileItemReader" scope="step">
        <property name="saveState" value="true"/>
        <property name="resource" value="#{jobParameters[upload.file.name]}"/>
        <property name="lineMapper" ref="edfLineMapper"/>
        <property name="linesToSkip" value="1"/> <!-- first line is header -->
      </bean>
      
      <bean class="org.springframework.beans.factory.config.CustomScopeConfigurer">
        <property name="scopes">
          <map>
            <entry key="step">
              <bean class="org.springframework.batch.core.scope.StepScope" />
            </entry>
          </map>
        </property>
      </bean>
    However, when I try to run the job, I get this:

    2009-03-06 09:49:56,194 WARN [FlatFileItemReader] (SimpleAsyncTaskExecutor-1 Input resource does not exist class path resource [#{jobParameters[upload.file.name]}]
    But the log from running my job shows:
    2009-03-06 09:49:55,830 DEBUG [BatchDeviceProcessingHelperImpl] (http-127.0.0.1-8080-1 Launching job EdfDelayedProvisioning with parameters {BATCH_UPLOAD_HISTORY_ID=5, upload.file.name=file:/tmp/edf-file-uploads/spaudiovox_20080805_005546.dat}
    Any ideas why this config is not working correctly?

  • #2
    Nevermind

    I think it was an ID10T error..

    Comment


    • #3
      Hi chudak, I seem to have the same problem, could you shed some light on why it is an ID1OT error?

      Code:
          <bean id="portfolioCheckSearchReader" class="dk.registret.services.batchjob.PortfolioCheckSearchReader">
              <property name="lineMapper">
                  <bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
                      <property name="lineTokenizer">
                          <bean class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
                              <property name="delimiter" value=";"/>
                              <property name="names" value="CustomerID,Name,Owner,CVRNumber,BirthDate,Address,PostalCode,CityName,Type" />
                          </bean>
                      </property>
                      <property name="fieldSetMapper" ref="portfolioFieldSetMapper"/>
                  </bean>
              </property>
              <property name="resource" value="classpath:./data/booking-#{jobParameters[bookingId]}.txt" />
          </bean>

      I seem to have the jobParameter set properly:
      JobExecution: id=0, startTime=Mon Mar 23 10:34:29 CET 2009, endTime=null, lastUpdated=Mon Mar 23 10:34:29 CET 2009, status=STARTED, exitStatus=exitCode=UNKNOWN;exitDescription=, job=[JobInstance: id=0, JobParameters=[{bookingId=testBookingId}], Job=[portfolioCheckJob]]
      But the resource isn't evaluated:
      2009-03-23 10:44:16,815 WARN [org.springframework.batch.item.file.FlatFileItemRe ader] - <Input resource does not exist class path resource [data/booking-#{jobParameters[bookingId]}.txt]>
      If i use a hardcoded value it works:
      Code:
      <property name="resource" value="classpath:./data/booking-testBookingId.txt" />

      Comment


      • #4
        I think the log you show is just a warning from the item reader to say that the file does not exist before the name is bound. Your reader is not working because it is not scope="step" (which chudak's was so his worked).

        Comment


        • #5
          Ah, yes i should have noticed that in the documentation.

          Thank you.

          Comment

          Working...
          X