File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes Exception with Range - org.springframework.beans.TypeMismatchException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Exception with Range - org.springframework.beans.TypeMismatchException" Watch "Exception with Range - org.springframework.beans.TypeMismatchException" New topic
Author

Exception with Range - org.springframework.beans.TypeMismatchException

Vis Deo
Ranch Hand

Joined: Jul 02, 2004
Posts: 40
I am trying to run Spring batch sample to read fixed length flat file
I am getting exception with Range definition
What can be changed in xml def?

Exception
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:


code snippet
ApplicationContext context=new ClassPathXmlApplicationContext(new String[]{"fixedLength.xml"});
BeanFactory factory=context;
FlatFileItemReader<CustomerCredit> itemReader = ((FlatFileItemReader<CustomerCredit>)factory.getBean("itemReader"));



This is xml definition
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd">

<bean id="itemReader" class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource" value="data/iosample/input/fixedLength.txt" />
<property name="lineMapper">
<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<property name="lineTokenizer">
<bean
class="org.springframework.batch.item.file.transform.FixedLengthTokenizer">
<property name="names" value="name,credit" />
<property name="columns" value="1-9,10-11" /> </bean>
</property>
<property name="fieldSetMapper">
<bean
class="org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper">
<property name="targetType"
value="org.springframework.batch.sample.domain.trade.CustomerCredit" />
</bean>
</property>
</bean>
</property>
</bean>
</beans>

thanks,
Vis
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 597

Configuration looks ok. Can you provide more of the exception trace?


Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Exception with Range - org.springframework.beans.TypeMismatchException
 
Similar Threads
Spring AOP not working
Hibernate with Spring
Spring AOP TX management error...
Spring / Hibernate / cxf problems connecting with oracle
running before I can crawl ( or how to add Spring to an existing Hibernate standalone app)