logo       

[xstream-dev] Re: was : [xstream-user] DefaultStyledDocument deserializatio: msg#00018

java.xstream.devel

Subject: [xstream-dev] Re: was : [xstream-user] DefaultStyledDocument deserialization problem

Hi list,

I wasn't sure this kind of remark had it's place on the user mailing list, so I'm sending it here instead. Since I'm a curious kind of person - sometimes - I went to look at the cvs changelogs to see how the issue mentionned below was fixed ;) While I was there looking at the latest changes, I tould maybe I could remind to reenable these tests, since I believe the fix for

XSTR-100 makes it possible to run these tests again on an headless server?
(Maybe with some adjustments to the tests themselves if they use awt classes ?


MAIN:joe:20040715210439 <http://cvs.xstream.codehaus.org/changelog/xstream?cs=MAIN:joe:20040715210439> by joe on 15 July 2004, 21:04:39 GMT (7 days ago) FontConverter test does not run if graphics environment is not available
MAIN:joe:20040710072353 <http://cvs.xstream.codehaus.org/changelog/xstream?cs=MAIN:joe:20040710072353> by joe on 10 July 2004, 07:23:53 GMT (13 days ago) Temporarily disabled test that fails on headless build server

Hope I'm not bothering ;)

Cheers,

greg


Joe Walnes wrote:

Sebastien... I've tracked down the bug and I believe it's now fixed.

Try out the snapshot: http://dist.codehaus.org/xstream/jars/xstream-SNAPSHOT.jar

cheers
-Joe

Sebpainter wrote:

Hi !

First of all I would like to congratulate all the XStream for its work : a simple-to-use library and really efficient...

However I have a problem when deserializing an instance of the javax.swing.text.DefaultStyledDocument class.
The problem is not really while deserializing : some private fields of this JDK class are mentionned as "transient" fields (like this one : private transient Vector listeningStyles;). So they are not serialized.

The problem starts when I use the deserialized object (with the 'fromXML' method) : those previous "transient" fields have not been initialized and their use via DefaultStyledDocument or other JDK classes methods raise a NullPointerException...

So I tried the unmarshal method to initialise those fields with the default constructor first, and then deserialize:

XStream xstream = new XStream();
DefaultStyledDocument doc = new DefaultStyledDocument();
String xml = xstream.toXML(doc);
DefaultStyledDocument tmpDoc = new DefaultStyledDocument();
doc = (DefaultStyledDocument) xstream.unmarshal(
new XppReader(new StringReader(xml)),
tmpDoc);

...but this code raise an exception (at the end of this message). Can someone tell me what is wrong with this code or give me a solution to serialize/deserialize a DefaultStyledDocument ?

Thanks in advance.

--
Sebastien



********************************************************
com.thoughtworks.xstream.converters.ConversionException: No such field javax.swing.text.DefaultStyledDocument.children
---- Debugging information ----
required-type : javax.swing.text.DefaultStyledDocument$SectionElement
cause-message : No such field javax.swing.text.DefaultStyledDocument.children
class : javax.swing.text.DefaultStyledDocument
message : No such field javax.swing.text.DefaultStyledDocument.children
line number : 4
path : /javax.swing.text.DefaultStyledDocument/buffer/root/children
cause-exception : com.thoughtworks.xstream.converters.reflection.ObjectAccessException
-------------------------------
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(Unknown Source)
at com.thoughtworks.xstream.core.ReferenceByXPathUnmarshaller.convertAnother(Unknown Source)
at com.thoughtworks.xstream.converters.reflection.ReflectionConverter.unmarshal(Unknown Source)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(Unknown Source)
at com.thoughtworks.xstream.core.ReferenceByXPathUnmarshaller.convertAnother(Unknown Source)
at com.thoughtworks.xstream.converters.reflection.ReflectionConverter.unmarshal(Unknown Source)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(Unknown Source)
at com.thoughtworks.xstream.core.ReferenceByXPathUnmarshaller.convertAnother(Unknown Source)
at com.thoughtworks.xstream.core.TreeUnmarshaller.start(Unknown Source)
at com.thoughtworks.xstream.core.ReferenceByXPathMarshallingStrategy.unmarshal(Unknown Source)
at com.thoughtworks.xstream.XStream.unmarshal(Unknown Source)
********************************************************







<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise