Skip to content

Unable to use Job Scope beans in a multi-threaded or partitioned step [BATCH-2269] #1335

Closed
@spring-projects-issues

Description

@spring-projects-issues

David Geary opened BATCH-2269 and commented

Attempting to access a JobScope bean from a worker thread in a thread pool as part of a multi-threaded or partitioned step gives the following exception

Caused by: java.lang.IllegalStateException: No context holder available for job scope
        at org.springframework.batch.core.scope.JobScope.getContext(JobScope.java:153)
        at org.springframework.batch.core.scope.JobScope.get(JobScope.java:92)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:338)

This is due to the fact the JobExecution is stored in a ThreadLocal and it isn't set up on the worker threads.


Affects: 3.0.1

Reference URL: http://stackoverflow.com/questions/24558703/multi-threaded-acces-to-job-scope-beans-in-spring-batch-3-0

18 votes, 21 watchers

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions