Hi,

to me this looks like you deserialize with that ReflectionConverter and 
serialize without it ... this will not work. XStream must be setup in the 
same way for both operations.

- Jörg




X wrote:

> So I made the update and it seemed to work, I was able to bring up the
> object.  But with testing I noticed that all the objects that I
> unmarshalled and then were updated and reserialized with xstream would
> cause the following exception when I would try to unmarshall it again:
> 
> 
> [exec] Caused by:
> 
com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$UnknownFieldException:
> No such field
> 
com.sun.org.apache.xerces.internal.dom.AttributeMap.com.sun.org.apache.xerces.internal.dom.NamedNodeMapImpl
> [exec] ---- Debugging information ---- [exec] field               :
> com.sun.org.apache.xerces.internal.dom.NamedNodeMapImpl [exec] class      
>         : com.sun.org.apache.xerces.internal.dom.AttributeMap
> [exec] required-type       :
> com.sun.org.apache.xerces.internal.dom.AttributeMap [exec] converter-type 
>     : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
> [exec] path                :
> 
/xxx.xxx.SignedDocument/template/template/com.sun.org.apache.xerces.internal.dom.NodeImpl/default/ownerNode/com.sun.org.apache.xerces.internal.dom.ElementImpl/default/attributes/com.sun.org.apache.xerces.internal.dom.NamedNodeMapImpl
> [exec] line number         : 566
> [exec] class[1]            :
> com.sun.org.apache.xerces.internal.dom.ElementImpl
> [exec] converter-type[1]   :
> com.thoughtworks.xstream.converters.reflection.SerializableConverter
> [exec] class[2]            :
> xxx.xxx.MyTemplate
> [exec] class[3]            : xxx.xxx.SignedDocument
> [exec] version             : 1.4.7
> 
> Is there anything I can do about this?
> 
> 
> 
> On Thursday, March 6, 2014 8:39 AM, X
> <xh...@yahoo.com> wrote: Thank you sooo much
> for your help!
> 
> 
> 
> 
> On Thursday, March 6, 2014 4:04 AM, Jörg Schaible
> <joerg.schai...@swisspost.com> wrote: Hi,
> 
> X wrote:
> 
>> I'm getting this exception:
>> 
> 
[exec]Causedby:com.thoughtworks.xstream.converters.ConversionException:Cannotdeserialize
>> [objectwithnewreadObject()/writeObject()methods
>> [[exec]----Debugginginformation
>> 
> 
[----[exec]class:com.sun.org.apache.xerces.internal.dom.AttributeMap[exec]required-
> type
>> [:com.sun.org.apache.xerces.internal.dom.AttributeMap[exec]converter-type
>> 
> 
[:com.thoughtworks.xstream.converters.reflection.SerializableConverter[exec]path
>> 
> 
[:/xxx.xxx.xxx.xxx.xxx.xxx.SignedDocument/template/template/com.sun.org.apache.xerces.internal.dom.NodeImpl/default/ownerNode/com.sun.org.apache.xerces.internal.dom.ElementImpl/default/attributes
>> [[exec]line number
>> 
> 
[:1183[exec]class[1]:com.sun.org.apache.xerces.internal.dom.ElementImpl[exec]class[2]:xxx.xxx.xxx.xxx.xxx.xxx.MyTemplate[exec]converter-
> type[1]:com.thoughtworks.xstream.converters.r
>>
> 
eflection.ReflectionConverter[exec]class[3]:xxx.xxx.xxx.xxx.xxx.xxx.SignedDocument[exec]version
>>:1.4.5[exec]-------------------------------
>> 
>> I know that the problem is that the xml file was created under JDK 6 and
>> since we've updated to JDK 7, the reflection-based converter broke.  I
>> did not write this code and have no experience with XStream though, so I
>> am not sure how to create the custom converter.  The xml I'm trying to
>> unmarshal from is a mess.  It's got an element named "template" of a
>> certain class type that is a child of another element with the same
>> "template" name but with a different class type.  And within the
>> inner-"template" element are all these sub-elements called
>> com.sun.org.apache.xerces.internal.dom.NodeImpl,
>> com.sun.org.apache.xerces.internal.dom.ChildNode,
>> com.sun.org.apache.xerces.internal.dom.ParentNode,
>> com.sun.org.apache.xerces.internal.dom.ElementImpl.  I just don't even
>> know where to start or what cl
>>ass I'm supposed to try to create a custom converter for.
> 
> This is really a nasty one. The problem is that the internal layout of the
> AttributeMap has changed. Actually the change happened in the parent class
> NamedNodeMapImpl. That one has now a method pair of readObject/writeObject
> to mask the fact that it manages its nodes no longer in a Vector but an
> arbitrary List implementation. The SerializableConverter detects this
> situation and - because in those methods can happen "anything - it is no
> longer able to deserialize.
> 
> Since those methods were not present in Java 6 and AttributeMap and its
> super classes were all Serializable and did lack such a method pair, the
> generated XML does actually not differ from the one that would have been
> produced by the ReflectionConverter itself. So in this special case you
> can get away registering a ReflectionConverter for AttributeMap:
> 
> ============== %< ================
> xstream.register(
> new ReflectionConverter(
> xstream.getMapper(),
> xstream.getReflectionProvider(),
> AttributeMap.class));
> ============== %< ================
> 
> The Java code and the XML will be compatible for both Java versions.
> 
> However, in the long run, you should think about custom converters for all
> those DOM types - or one for the root element of the DOM objects in your
> classes (typically a Document) and write/recreate the XML structure using
> the methods of XStream's reader/writer.
> 
> Cheers,
> Jörg
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
> 
> http://xircles.codehaus.org/manage_email
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
> 
> http://xircles.codehaus.org/manage_email
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
> 
>     http://xircles.codehaus.org/manage_email



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to