-
Mar 5th, 2009, 11:07 AM
#1
Reading from XML File having Error
HI,
I am trying the run the xmlStaxJob job which read from XML file but i am getting an error
SEVERE: Job Terminated in error:
java.lang.NullPointerException
at org.springframework.batch.core.launch.support.Comm andLineJobRunner.start(CommandLineJobRunner.java:2 05) at org.springframework.batch.core.launch.support.Comm andLineJobRunner.ma
in(CommandLineJobRunner.java:252)Mar 5, 2009 10:58:30 AM org.springframework.context.support.AbstractApplic ationC
ontext doClose
Please let me know if i am doing something wrong.
XML File
?xml version="1.0" encoding="UTF-8"?>
<records>
<trade xmlns="http://springframework.org/batch/sample/io/oxm/domain">
<isin>XYZ0001</isin>
<quantity>5</quantity>
<price>11.39</price>
<customer>Customer1</customer>
</trade>
<trade xmlns="http://springframework.org/batch/sample/io/oxm/domain">
<isin>XYZ0002</isin>
<quantity>2</quantity>
<price>72.99</price>
<customer>Customer2c</customer>
</trade>
</records>
Here is my Job.
<?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
="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/schem...-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schem...ng-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schem...ing-tx-2.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd">
<description>
Batch Byte Process
</description>
<import resource="data-source-context.xml" />
<bean id="jobRepository"
class="org.springframework.batch.core.repository.s upport.JobRepositoryFactoryBean">
<property name="databaseType" value="mysql" />
<property name="dataSource" ref="dataSourceMYSQL" />
<property name="transactionManager" ref="transactionManager" />
</bean>
<bean id="simpleStep" class="org.springframework.batch.core.step.item.Si mpleStepFactoryBean"
abstract="true">
<property name="transactionManager" ref="transactionManager" />
<property name="jobRepository" ref="jobRepository" />
<property name="startLimit" value="100" />
<property name="commitInterval" value="1" />
</bean>
<bean id="mapJobRepository" class="org.springframework.batch.core.repository.s upport.MapJobRepositoryFactoryBean" >
<property name="transactionManager" ref="transactionManager"/>
</bean>
<bean id="xmlByteProcessJob" class="org.springframework.batch.core.job.SimpleJo b">
<property name="steps">
<bean id="step1" parent="simpleStep">
<property name="itemReader">
<bean
class="org.springframework.batch.item.xml.StaxEven tItemReader">
<property name="fragmentRootElementName"
value="trade" />
<property name="resource"
value="file:C:\xmlInput\20070918.testStream.xmlFil eStep.xml" />
<property name="fragmentDeserializer">
<bean
class="org.springframework.batch.item.xml.oxm.Unma rshallingEventReaderDeserializer">
<constructor-arg>
<bean
class="org.springframework.oxm.xstream.XStreamMars haller">
<property name="aliases"
ref="aliases" />
</bean>
</constructor-arg>
</bean>
</property>
</bean>
</property>
<property name="itemWriter" ref="tradeStaxWriter" />
</bean>
</property>
<property name="jobRepository" ref="jobRepository" />
<property name="restartable" value="true" />
</bean>
<bean class="org.springframework.batch.item.xml.StaxEven tItemWriter"
id="tradeStaxWriter">
<property name="resource"
value="file:C:\xmlInput\20070918.testStream.xmlFil eStep.output.xml" />
<property name="serializer" ref="tradeMarshallingSerializer" />
<property name="rootTagName" value="trades" />
<property name="overwriteOutput" value="true" />
</bean>
<bean
class="org.springframework.batch.item.xml.oxm.Mars hallingEventWriterSerializer"
id="tradeMarshallingSerializer">
<constructor-arg>
<bean
class="org.springframework.oxm.xstream.XStreamMars haller">
<property name="aliases" ref="aliases" />
</bean>
</constructor-arg>
</bean>
<util:map id="aliases">
<entry key="trade"
value="us.tn.state.trust.batch.byteProcess.domain. Trade" />
<entry key="isin" value="java.lang.String" />
<entry key="quantity" value="long" />
<entry key="price" value="java.math.BigDecimal" />
<entry key="customer" value="java.lang.String" />
</util:map>
<bean id="customEditorConfigurer" class="org.springframework.beans.factory.config.Cu stomEditorConfigurer">
<property name="customEditors">
<map>
<entry key="int[]">
<bean class="org.springframework.batch.support.IntArrayP ropertyEditor" />
</entry>
<entry key="org.springframework.batch.item.file.transform .Range[]">
<bean class="org.springframework.batch.item.file.transfo rm.RangeArrayPropertyEditor" />
</entry>
<entry key="java.util.Date">
<bean class="org.springframework.beans.propertyeditors.C ustomDateEditor">
<constructor-arg>
<bean class="java.text.SimpleDateFormat">
<constructor-arg value="yyyyMMdd" />
</bean>
</constructor-arg>
<constructor-arg value="false" />
</bean>
</entry>
</map>
</property>
</bean>
<bean id="logAdvice" class="org.springframework.batch.sample.advice.Pro cessorLogAdvice" />
<bean id="eventAdvice" class="org.springframework.batch.sample.advice.Ste pExecutionApplicationEventAdvice" />
</beans>
Pls. help..........
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