0

Hello we are integrating spring batch in my spring boot project but i am facing with this exceptionScope '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

Here my step scope bean config class :

@Bean 
@StepScope
public StaxEventItemReader<Document> xmlFileItemReader(@Value("#{jobParameters[fullPathFileName]}") String pathToFile) {
    StaxEventItemReader<Document> xmlFileReader = new StaxEventItemReader<>();
    xmlFileReader.setResource(new FileSystemResource(pathToFile));
    xmlFileReader.setFragmentRootElementName("Document");

    Jaxb2Marshaller pimMarshaller = new Jaxb2Marshaller();
    pimMarshaller.setClassesToBeBound(Document.class);

    xmlFileReader.setUnmarshaller(pimMarshaller);
    return xmlFileReader;
}

My main runnable class is annotated with @EnableBatchProcessing

Junaid Akhtar
  • 569
  • 3
  • 7
  • 17
  • Hello, your main runnable or batchConfig is annotated with @Configuration, @EnableBatchProcessing? – zedtimi Mar 30 '18 at 14:59
  • Main runnable , i tried with both but no luck. – Junaid Akhtar Mar 30 '18 at 17:56
  • Unfortunately, spring error messages are uninformative. The symptom may be the same, but the root cause unrelated, at least to the typical programmer who is not a guru on spring internals. this may be an FAQ that needs to be turned into a "how to find out why Spring can't find the beans I can see are there" – pojo-guy Mar 25 '19 at 15:49
  • @user177800 Also, the bug that the answer linked as duplicate points to has been resolved. It is likely that this user's issue is not related to that answer. – pojo-guy Mar 25 '19 at 15:54

1 Answers1

-1

use stepscope as below XMl config :

<bean class='org.springframework.batch.core.scope.StepScope" />

if Java config : @Bean @StepScope

Deb
  • 1