I have a FixedLengthTokenizer for a FlatFileItemReader like so:
But when initializing the container, I get an IllegalArgumentException when Spring tries to create the columns Range[] from the provided String in the FixedLengthTokenizer.Code:<bean id="itemReader" class="org.springframework.batch.item.file.FlatFileItemReader"> <property name="resource" value="classpath:data/72ack.2007070231542.out"></property> <property name="lineTokenizer" ref="fixedFileTokenizer" /> <property name="fieldSetMapper"> <bean class="org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper" > <property name="prototypeBeanName" value="ack" /> </bean> </property> </bean> <bean id="fixedFileTokenizer" class="org.springframework.batch.item.file.transform.FixedLengthTokenizer"> <property name="names" value="linkageNumber,contact,paymentType,returnReasonCode,paymentAmount" /> <property name="columns" value="1-21,22-51,52-53,54-56,57-68" /> </bean>
Why can't Spring figure out that it needs to use a RangeArrayPropertyEditor? (Assuming that's what it should be.) I'm doing this the way the Batch docs show, and they don't mention having to jump through extra hoops to force the use of a certain PropertyEditor, so what's up? I've tried the column and names properties with and without spaces between values. Fails the same either way.Code:[some exceptions omitted] Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [org.springframework.batch.item.file.transform.Range[]] for property 'columns'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required type [org.springframework.batch.item.file.transform.Range] for property 'columns[0]': no matching editors or conversion strategy found at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:391) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1253) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1214) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:978) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:462) ... 46 more Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required type [org.springframework.batch.item.file.transform.Range] for property 'columns[0]': no matching editors or conversion strategy found at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:238) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:124) at org.springframework.beans.TypeConverterDelegate.convertToTypedArray(TypeConverterDelegate.java:385) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:205) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138) at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:386) ... 50 more


Reply With Quote