Hi,
I am trying to access the records in a text file and storing them in an other text file. I included the exception 'FlatFileParseException' in <batch:skippable-exception-classes> tag so that any bad record should be skipped. However, when I am accessing the output file, only records which occur before exception-causing record are processed and the records which occur after the exception-causing record are not getting processed. Also the error stack trace shows exception as non-skippable.
Below are the excerpts from my code-
input file:
1,a,b
2,c,d
3,e,f
problem,g,h
5,i,j
6,k,l
bold one is the bad record which should be skipped ideally.
output file:
1-ab
2-cd
code:
error stacktrace:Code:<batch:job id="FileToFileJob"> <batch:step id="step1"> <batch:tasklet transaction-manager="transactionManager"> <batch:chunk reader="FileReader" processor="FileProcessor" writer="FileWriter" commit-interval="2" skip-limit="10"> <batch:skippable-exception-classes> <batch:include class="org.springframework.batch.item.file.FlatFileParseException"/> </batch:skippable-exception-classes> </batch:chunk> </batch:tasklet> </batch:step> </batch:job>
Mapper:Code:17:30:37,208 ERROR main FlatFileItemReader:182 - Parsing error at line: 4 in resource=URL [file:C:/ankitFilesRead/text.txt], input=[,g,h] org.springframework.batch.item.file.FlatFileParseException: Parsing error at line: 4, input=[problem,g,h]................. Caused by: java.lang.NumberFormatException: Unparseable number:problem ..................... 17:30:37,223 ERROR main AbstractStep:213 - Encountered an error executing the step: class org.springframework.batch.core.step.skip.NonSkippableReadException: Non-skippable exception during read...............
Can you please help me understand why the records below the row- problem,g,h are not getting printed in output file and why the exception is being thrown as non-skippable?Code:public Employee mapFieldSet(FieldSet fs) { if(fs == null) { return null; } Employee emp = new Employee(); emp.setId(fs.readInt("id")); emp.setFirstName(fs.readString("firstName")); emp.setLastName(fs.readString("lastName")); return emp; }


Reply With Quote
