I have XML-based beans defined as
When the application context is loaded, I get the following exception.Code:<bean class = "org.springframework.batch.core.scope.StepScope"/> <bean id = "genericStep" class = "org.springframework.batch.core.step.item.SimpleStepFactoryBean" abstract = "true"> ... <bean id = "myStep" parent = "genericStep" scope = "step"> ...
So it appears that the system expects the bean to be a prototype, which makes sense. But I can't figure out how to force that. I tried configuring SimpleStepFactoryBean to have singleton=true. That didn't work.Code:Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.myStep': Scope 'step' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No context holder available for step scope at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:339) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:33) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:182) at $Proxy18.getName(Unknown Source) at org.springframework.batch.core.job.flow.support.state.StepState.<init>(StepState.java:40) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126) ... 87 more Caused by: java.lang.IllegalStateException: No context holder available for step scope at org.springframework.batch.core.scope.StepScope.getContext(StepScope.java:197) at org.springframework.batch.core.scope.StepScope.get(StepScope.java:139) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:325)
Anyone have suggestions? Thanks.


Reply With Quote