Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8905785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:28:53+00:00 2026-06-15T02:28:53+00:00

I have a Spring Batch job consisting of two steps (so far). The first

  • 0

I have a Spring Batch job consisting of two steps (so far).

The first step in the job is implemented in a tasklet. It takes the comma-separated value (CSV) files that need to be processed (using a good chunk of business logic to determine which ones those are), and copies them into a “drop zone” directory.

The second step is configured for chunk-oriented processing, with a reader and writer. The reader is a MultiResourceItemReader… which looks for all CSV files in the drop zone directory, and delegates each to the “real” reader (which parses the CSV).

My problem is that even though the first step succeeds, the second step fails to find any CSV files in the drop zone directory. Interestingly, if I immediately run the batch job again… then the second step does find and process the files!

I am speculating, but it looks like Spring Batch resolves the second step’s wildcard pattern at the outset… rather than waiting until it’s time for the second step to run. Even though the first step copies the files that it is supposed to, the second step has already decided that there are no files there.

I am fairly new to Spring Batch, and still learning my way around. Is there something obvious with context or scope that I am missing here? The relevant portions of my job definition are below. Thanks!

...
<!-- JOB DEFINITION -->
<job id="notificationJob" xmlns="http://www.springframework.org/schema/batch">
    <step id="copyFilesToLocal">
        <tasklet transaction-manager="jobRepositoryTransactionManager" ref="getFilesTasklet" />
        <next on="COMPLETED" to="processFiles"/>
    </step>
    <step id="processFiles">
        <tasklet transaction-manager="ecommerceTransactionManager">
            <chunk reader="multiFileReader" writer="notificationEmailWriter" commit-interval="1" />
        </tasklet>
    </step>
</job>

<!-- FIRST STEP -->
<bean id="getFilesTasklet" class="com.mypackage.FileMovingTasklet">
    <property name="localDao">
        <bean class="com.mypackage.BatchLocalDao">
            <property name="dataSource" ref="jobRepositoryDataSource" />
        </bean>
    </property>
    <property name="sourceDirectory">
        <bean id="sourceDirectory" class="org.springframework.core.io.FileSystemResource">
            <constructor-arg value="/mnt/source-directory" />
        </bean>
    </property>
    <property name="destinationDirectory">
        <bean id="destinationDirectory" class="org.springframework.core.io.FileSystemResource">
            <constructor-arg value="/home/myuser/drop-zone" />
        </bean>
    </property>
</bean>


<!-- SECOND STEP -->
<bean id="multiFileReader" class="org.springframework.batch.item.file.MultiResourceItemReader">
    <property name="resources" value="file://home/myuser/drop-zone/*.csv" />
    <property name="delegate" ref="myFileReader" />
</bean>
...
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:28:54+00:00Added an answer on June 15, 2026 at 2:28 am

    Your “multiFileReader” needs to be scope=”step”, so it defers the pattern expansion (initialization of bean properties) until the step is executed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The issue is this: I have a Spring Batch job with a single step.
I have several jobs in spring batch. The first job is kind of a
I have a Spring Batch process which has following kind of code. <step id=step1
I'm a newbie in Spring Batch. I have inherited a batch process implemented with
Using spring-batch and JPA (provided by hibernate). I have a step that does the
I have created a spring-batch job. My reader class reads the data from the
I have a spring-batch job that converts various bank statements into my app. There
What I want to achieve: I have set up a Spring Batch Job containing
i have a spring batch job which needs to be scheduled at specific hour
I have a Spring-Batch job that I launch from a Spring MVC controller. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.