1

I am writing a spring batch job. The job reads from a database, does some processing and then writes to a file.

It works single threaded without a partition step. So far so good.

I now want to enhance the job to add a Partitioner and read the rows from the database partitioned by the values in a particular column.

This is the code I have so far...

http://pastebin.com/wwSjrNhv

When I try and execute it I get the error below.

java.util.concurrent.ExecutionException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.readStgDbAndExportMasterListStep': Scope 'job' 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 job scope

The full error can be seen here...

http://pastebin.com/jyARDH51

Can someone assist me with understanding what parts of a job need to be in step scope and what parts of a job need to be defined as JobScope especially in my use case where I am trying to multi-thread my jobs so as to help me resolve this?

thanks

Richie
  • 4,989
  • 24
  • 90
  • 177
  • 1
    At first glance I see a configuration error that I previously made as well and in the answer to http://stackoverflow.com/questions/37238813/spring-batch-looping-a-reader-processor-writer-step @HansjoergWingeier showed me not to instantiate your Steps, Readers, Processers and Writers as Spring-Beans. Only your job instance has to be a Spring Bean. Have a try with that an see if its any help. – Sander_M Aug 03 '16 at 13:27
  • Thanks. I had a go at this and u think it's simplified my job – Richie Aug 06 '16 at 13:13

0 Answers0