So to recap, the issue you are experiencing is that the ItemReader is returning an instance of XmlAnyTypeImpl instead of your intended domain class. This causes the ClassCastException on the ItemProcessor because your processor is expecting your domain class but the ItemWriter is fine with accepting the XmlAnyTypeImpl class that gets passed if no processor exists.
When we look at the job configuration you have posted, we see that your marshaller has been configured as below:
Code:
<bean id="castorMarshaller" class="org.springframework.oxm.castor.CastorMarshaller"/>
While this does create an instance of the CastorMarshaller, per the documentation (see here: http://static.springsource.org/sprin...arshaller.html) you need to provide a bit of additional information for it to know what object to serialize/deserialzie to. I tested the below configuration with a simple XML file with no issues.
Code:
<bean id="customerFileReader" class="org.springframework.batch.item.xml.StaxEventItemReader">
<property name="fragmentRootElementName" value="customer" />
<property name="resource" ref="customerFile" />
<property name="unmarshaller" ref="customerMarshaller" />
</bean>
<bean id="outputFile" class="org.springframework.core.io.FileSystemResource" scope="step">
<constructor-arg value="/tmp/customerProcessed.xml"/>
</bean>
<bean id="xmlOutputWriter" class="org.springframework.batch.item.xml.StaxEventItemWriter">
<property name="resource" ref="outputFile" />
<property name="marshaller" ref="customerMarshaller" />
<property name="rootTagName" value="customers" />
</bean>
<bean id="customerMarshaller" class="org.springframework.oxm.castor.CastorMarshaller">
<property name="targetClass" value="org.springsource.batch.domain.Customer"/>
</bean>