Results 1 to 2 of 2

Thread: XStream Marshalling Strangeness

  1. #1
    Join Date
    Jan 2007
    Posts
    2

    Default XStream Marshalling Strangeness

    I am using xstream to marshal an XML view and it works differently depending on the ClassName of the object I'm trying to marshal.

    On one output I have a simple output

    Code:
    <?xml version="1.0"?>
    <store hash="FJSF">
    	<name>The Video Store</name>
    	<phone>(323) 999-3322</phone>
    	<defaultMedia type="PICTURE">
    		<url>http://images.google.com/images/3/215.jpg</url>
    	</defaultMedia>
    </store>
    On another Class Name with similar properties I get:

    Code:
    <?xml version="1.0"?>
    <org.springframework.validation.BeanPropertyBindingResult>
    	<nestedPath/>
    	<nestedPathStack serialization="custom">
    		<unserializable-parents/>
    		<vector>
    			<default>
    				<capacityIncrement>0</capacityIncrement>
    				<elementCount>0</elementCount>
    				<elementData>
    					<null/>
    					<null/>
    					<null/>
    					<null/>
    					<null/>
    					<null/>
    					<null/>
    					<null/>
    					<null/>
    					<null/>
    				</elementData>
    			</default>
    		</vector>
    	</nestedPathStack>
    	<objectName>VenueModel</objectName>
    	<messageCodesResolver class="org.springframework.validation.DefaultMessageCodesResolver">
    		<prefix/>
    	</messageCodesResolver>
    	<errors class="linked-list"/>
    	<suppressedFields/>
    	<target class="venue" hash="sdfklj">
    		<name>The Venue</name>
    		<phone>(805)555-1212</phone>
    		<defaultMedia type="PICTURE">
    			<url>http://images.google.com/images/4/222.jpg</url>
    		</defaultMedia>
    	</target>
    </org.springframework.validation.BeanPropertyBindingResult>
    Has anyone seen something like that, this problem has been most confusing.

  2. #2
    Join Date
    Jan 2007
    Posts
    2

    Default

    So after some digging the problem was found.

    It comes from doing the Rest based Annotations and making assumptions of what the model is if it isn't specifically defined.

    So in my controller i have something similar to:
    Code:
        @RequestMapping(value = "/venue/{hashCode}", method=RequestMethod.GET)
        public VenueModel getVenueByHashCode(@PathVariable String hashCode) {
    		return rs.getWrapperByHashCode(hashCode, VenueModel.class);
        }
    The problem we found was that in MarshallingView.locateToBeMarshalled(Map model) is iterating through the keys if modelKey is not defined and looks for a model that it can support and ships that off to the XStreamMarshaller. So the map had two keys venueModel and org.springframework.validation.BindingResult.venue Model. So the fix is to define the modelKey property of the MarshallingView and adding the annotation

    Code:
     @ModelAttribute(value = "<whatever you named the model key in marshallingView>")

    Or make a change to Spring... make the Map to a LinkedHashMap.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •