Announcement Announcement Module
Collapse
No announcement yet.
Getting IllegalArgumentException when using XStreamMarshaller Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting IllegalArgumentException when using XStreamMarshaller

    Hi all,

    I'm new to spring and spring batch. I've checked these and other forums for a possible solution to my problem with no luck so far. Hopefully, someone here can guide me in the right direction.

    I'm adding the ability to read an xml file to an existing spring batch app that just reads and writes to a database using
    "org.springframework.oxm.xstream.XStreamMarshaller ". When I run the application I get the following exception:

    2012-09-26 16:21:39,629 main ERROR org.springframework.web.context.ContextLoader - Context initialization failed
    java.lang.IllegalArgumentException: Mapped value [org.springframework.batch.item.file.transform.Rang eArrayPropertyEditor] for custom editor key [org.springframework.batch.item.file.transform.Rang e[]] is not of required type [java.beans.PropertyEditor]

    at org.springframework.beans.factory.config.CustomEdi torConfigurer.postProcessBeanFactory(CustomEditorC onfigurer.java:163)
    at org.springframework.context.support.AbstractApplic ationContext.invokeBeanFactoryPostProcessors(Abstr actApplicationContext.java:554)
    at org.springframework.context.support.AbstractApplic ationContext.invokeBeanFactoryPostProcessors(Abstr actApplicationContext.java:537)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:363)
    at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:254)
    at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:198)
    at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 45)
    at org.apache.catalina.core.StandardContext.listenerS tart(StandardContext.java:3972)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4467)



    My beans are as follows:
    Code:
    	<bean  id="sponsorReader" scope="step"
    		class="org.springframework.batch.item.xml.StaxEventItemReader">
    		<property name="fragmentRootElementName" value="rec" />
    		<property name="resource" value="P:\work\KCO-223\sponsor-code-files\REMS.SPT.DLY.xml" />
    		<property name="unmarshaller" ref="sponsorMarshaller" />
    	</bean>
    	
    	<bean id="sponsorMarshaller"
    		class="org.springframework.oxm.xstream.XStreamMarshaller">
    		<property name="aliases">
    		<util:map id="aliases" >
    		<entry key="rec" value="edu.ucdavis.kc.batch.domain.Sponsor" />
        	<entry key="sponsorCode" value="java.lang.String" />
        	<entry key="sponsorName" value="java.lang.String" />
         	<entry key="sponsorCategoryCode" value="java.lang.String" />
        	<entry key="sponsorAgencyCode" value="java.lang.String" />
        	<entry key="sponsorSubAgencyCode" value="java.lang.String" />
        	<entry key="sponsorForeignIndicator" value="java.lang.String" />
        	<entry key="sponsorForeignCountry" value="java.lang.String" />
        	<entry key="sponsorNameAlternate" value="java.lang.String" />
        	<entry key="parentSponsorCode" value="java.lang.String" />
        	<entry key="changeDate" value="java.util.Date" />
        	<entry key="requestiongLocation" value="java.lang.String" />
        	<entry key="requestDate" value="java.util.Date" />
        	<entry key="replacementSponsorCode" value="java.lang.String" />
        	<entry key="sponsorStatus" value="java.lang.String" />
        	<entry key="sponsorDuns" value="java.lang.String" />
        	<entry key="address1" value="java.lang.String" />
        	<entry key="address2" value="java.lang.String" />
        	<entry key="address3" value="java.lang.String" />
        	<entry key="address4" value="java.lang.String" />
        	<entry key="city" value="java.lang.String" />
        	<entry key="state" value="java.lang.String" />
        	<entry key="postalCode" value="java.lang.String" />
        	<entry key="url" value="java.lang.String" /> 
        	<entry key="sponsorAcronym" value="java.lang.String" />
        	<entry key="deactivatedDate" value="java.util.Date" />
    		</util:map>
    		</property>
    	</bean>


    I initially thought it might be a version incompatibility issue since I had to find and load several jars to to CLASSNOTFOUND exceptions. See capture.jpg for my class path.

    I'm sure this is a pedestrian issue but being a newby, I'm having some difficulty locating the problem. If anyone can shed some light on this for me, I'd greatly appreciate it.

  • #2
    Comments from: org.springframework.beans.factory.config.CustomEdi torConfigurer

    * <p><b>NOTE:</b> Custom property editors registered with this configurer do
    * <i>not</i> apply to data binding. Custom editors for data binding need to
    * be registered on the {@link org.springframework.validation.DataBinder}:
    * Use a common base class or delegate to common PropertyEditorRegistrar
    * implementations to reuse editor registration there.


    The method within this class that is throwing the exception is: postProcessBeanFactory

    A customEditors is being used but it doesn't implement the right type. A java.beans.PropertyEditor

    Is it edu.ucdavis.kc.batch.domain.Sponsor?

    Good luck,

    Jeff

    Comment

    Working...
    X