-
Oct 7th, 2010, 10:20 AM
#1
Newbie - skippable-exception-classes FlatFileParseException
Disclaimer.. - I'm totally new to Spring Batch.
I'm trying to write a job that reads in a csv file for processing. I'll include my config at the bottom of the post. Everything seems to work fine. I've specified which line to start on, but when the end of the file is reached there are two lines at the bottom that I don't want to process. I thought I could use the "skippable-exception-classes" property to "skip" these two lines. I get an exception thrown though; I'll put that below too.
Should this work?
thanks,
John
---
config --
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/batch http://www.springframework.org/schem...-batch-2.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<description>Mickey Mouse batch job.</description>
<job id="mickeyMouseLoadJob" xmlns="http://www.springframework.org/schema/batch">
<step id="mickeyMouseLoad">
<tasklet>
<chunk reader="mickeyMouseFileItemReader" writer="mickeyMouseWriter" commit-interval="10" skip-limit="2">
<skippable-exception-classes>
<include class="org.springframework.batch.item.file.FlatFil eParseException"/>
</skippable-exception-classes>
</chunk>
</tasklet>
</step>
</job>
<bean id="mickeyMouseFileItemReader" class="org.springframework.batch.item.file.FlatFil eItemReader">
<property name="resource" value="file:k:\marketdata\disney\cartoons\animals\ 201009-comments.csv"/>
<property name="lineMapper">
<bean class="org.springframework.batch.item.file.mapping .DefaultLineMapper">
<property name="lineTokenizer">
<bean class="org.springframework.batch.item.file.transfo rm.DelimitedLineTokenizer">
<property name="names" value="Date,PnodeID,Name,100,200,300,400,500,600,7 00,800,900,1000,1100,1200,1300,1400,1500,1600,1700 ,1800,1900,2000,2100,2200,2300,2400, "/>
</bean>
</property>
<property name="fieldSetMapper">
<bean class="com.fun.disney.MyFieldSetMapper"/>
</property>
</bean>
</property>
<property name="linesToSkip" value="6"/>
</bean>
<bean id="mickeyMouseWriter" class="com.fun.disney.MyItemWriter"/>
</beans>
--
Stack Trace
--
org.springframework.batch.item.file.FlatFileParseE xception: Parsing error at line: 517, input=[End of LMP Data]
at org.springframework.batch.item.file.mapping.Defaul tLineMapper.mapLine(DefaultLineMapper.java:49)
at org.springframework.batch.item.file.FlatFileItemRe ader.doRead(FlatFileItemReader.java:188)
at org.springframework.batch.item.support.AbstractIte mCountingItemStreamItemReader.read(AbstractItemCou ntingItemStreamItemReader.java:85)
at org.springframework.batch.core.step.item.SimpleChu nkProvider.doRead(SimpleChunkProvider.java:90)
at org.springframework.batch.core.step.item.FaultTole rantChunkProvider.read(FaultTolerantChunkProvider. java:87)
at org.springframework.batch.core.step.item.SimpleChu nkProvider$1.doInIteration(SimpleChunkProvider.jav a:108)
at org.springframework.batch.repeat.support.RepeatTem plate.getNextResult(RepeatTemplate.java:367).... (lots more)
Caused by: org.springframework.batch.item.file.transform.Inco rrectTokenCountException: Incorrect number of tokens found in record: expected 28 actual 1
at org.springframework.batch.item.file.transform.Abst ractLineTokenizer.tokenize(AbstractLineTokenizer.j ava:123)
at org.springframework.batch.item.file.mapping.Defaul tLineMapper.mapLine(DefaultLineMapper.java:46)
... 64 more
-
Oct 8th, 2010, 05:59 PM
#2
Looks OK to me. What happens if you simply skip java.lang.Exception?
(Please use [code][/code] tags to post code and stack traces.)
-
Oct 25th, 2010, 12:49 PM
#3
newbie error of course....
I'm both very happy and very embarrassed to admit the problem was mine... the exception was skipped, the stack trace was just sent to the logger...
I assumed that the log mean the job was stopped... it worked fine, as advertised, the job continued on to completion, skipping any exception I included in the configuration.
thanks,
John
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules