EDIT
I created a test project that replicates the issue. It can be found at https://github.com/tomverelst/test-batch.
First run the maven co
I can not provide you an actual answer (yet), but I've debugged the example you have provided and this is happening:
@Configuration
definition reader sees @StepScope
annotation which is annotated with @Scope(value = "step", proxyMode = ScopedProxyMode.TARGET_CLASS)
reader
while the original bean is registered as scopedTarget.reader
.StepScope
kicks in and post-processes step
scoped beans. It detects the CGLIB extended reader
definition and tries to create proxy for that => ERROR.There are two proxying mechanisms in conflict. There is something really weird going on and it seems to me that this can never work. Will try to search through Spring JIRA.
UPDATE
Found solution - you need to disable auto-proxying for the step scope:
<bean class="org.springframework.batch.core.scope.StepScope">
<property name="autoProxy" value="false" />
</bean>
Easly remove <bean class="org.springframework.batch.core.scope.StepScope" />
from your configuration file; you don't need to add it explicit because is defined in batch namespace (as described in official documentation of Step scope)