0

I am writing a Spring Batch program which reads a file, processes then writes to a db. While executing the batch there may be errors in different stages of the program. For example:

  • An error can occur while parsing the line in ItemReader
  • An error can occur while processing the line in ItemProcessor
  • An error can occur while writing the line to the db ItemWriter

So my question is, how can i get the line number of the error? Is there an easy way to get this?

Edit: I already found the link about FieldSetMapper SpringBatch - Get Line Number on FieldSetMapper. But my question includes ItemProcessor and ItemWriter also.

Thanks for the help.

  • Possible duplicate of [SpringBatch - Get Line Number on FieldSetMapper](https://stackoverflow.com/questions/23705400/springbatch-get-line-number-on-fieldsetmapper) – Luca Basso Ricci Oct 18 '17 at 13:52
  • Actually i researched this a lot and found that solution but this is not the same question and answer with the given link @LucaBassoRicci. The given link describes how to get the line for `ItemReader`. I am asking for `ItemProcessor` and `ItemWriter` also. – Ali Doruk Baykal Oct 18 '17 at 14:24
  • 3
    The answer doesn't change from the question @LucaBassoRicci referenced. You need to inject the line number in the reader. From there, it would be available in the `ItemProcessor` and `ItemWriter` as long as you don't drop that data for some reason. – Michael Minella Oct 18 '17 at 14:43

0 Answers0