I will branch away from my previous post for a quick issue I ran into. I was working with the simpleframework xml packages on a new project. During the deserializing of a response message in xml I ran across an issue which the exception was unclear about. The exception was
Caused by: org.simpleframework.xml.core.Element Exception: Unable to determine type for @org.simpleframework.xml.ElementList
At first glance the error looked like it was due to either a missing element in the xml or the compile of my classes was incorrect. It was actually neither. The error was due to my definition class for the parent element contained a duplicate definition of a child element which didn't belong.
Example of xml
<messageNode>
<element1>
<element2/>
<element1/>
<element3/>
<messageNode/>
code snipit
public abstract class MessageNode
@Element(name="element1", required=false,data=false )
private Element1 element1;
@Element(name="element3", required=false,data=false )
private Element3 element3;
public abstract class Element1
@Element(name="element2", required=false,data=false )
private Element2 element2;
@Element(name="element3", required=false,data=false )
private Element3 element3;
As you can see the definition of element3 is included in both class definitions. The simple framework xml creates a map of the nodes. when an element is included this way it creates an issue with the values stored in the map. My suggestion when you receive this error is to do a file search for the string of the element name. Double check the definition of the expected element is in the appropriate place.
Friday, May 14, 2010
Subscribe to:
Posts (Atom)