Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Serializing problem...

Reply
Thread Tools

Serializing problem...

 
 
Andreas Beresko
Guest
Posts: n/a
 
      02-14-2005
Hi,

I'm trying to serialize a JTree and get following error on runtime:

java.io.NotSerializableException:
javax.swing.plaf.basic.BasicTextUI$UpdateHandler
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.access$100(Unknown Source)
....
at java.io.ObjectOutputStream.writeObject(Unknown Source)
at javax.swing.tree.DefaultMutableTreeNode.writeObjec t(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.lang.reflect.Method.invoke(Unknown Source)
....
at javax.swing.JTree.writeObject(Unknown Source)
....

very suprising: i was able to serialize it with version 1.4.2 but now in
version 1.5 i can't - a bug???

best regards
Andreas


 
Reply With Quote
 
 
 
 
John C. Bollinger
Guest
Posts: n/a
 
      02-14-2005
Andreas Beresko wrote:

> Hi,
>
> I'm trying to serialize a JTree and get following error on runtime:
>
> java.io.NotSerializableException:
> javax.swing.plaf.basic.BasicTextUI$UpdateHandler
> at java.io.ObjectOutputStream.writeObject0(Unknown Source)
> at java.io.ObjectOutputStream.access$100(Unknown Source)
> ...
> at java.io.ObjectOutputStream.writeObject(Unknown Source)
> at javax.swing.tree.DefaultMutableTreeNode.writeObjec t(Unknown Source)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> ...
> at javax.swing.JTree.writeObject(Unknown Source)
> ...
>
> very suprising: i was able to serialize it with version 1.4.2 but now in
> version 1.5 i can't - a bug???


Maybe. JTree implements Serializable, but whether you can serialize a
particular JTree instance depends also on all the other objects in the
the JTree's graph. If you have added a non-serializable object directly
or indirectly to the JTree's model, for instance, then you can expect to
receive NotSerializableExceptions when you try to serialize the tree.
Seeing DefaultMutableTreeNode.writeObject() in the stack trace makes me
think that this is what has happened.

--
John Bollinger
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
 
Andreas Beresko
Guest
Posts: n/a
 
      02-14-2005
> Maybe. JTree implements Serializable, but whether you can serialize a
> particular JTree instance depends also on all the other objects in the the
> JTree's graph. If you have added a non-serializable object directly or
> indirectly to the JTree's model, for instance, then you can expect to
> receive NotSerializableExceptions when you try to serialize the tree.
> Seeing DefaultMutableTreeNode.writeObject() in the stack trace makes me
> think that this is what has happened.


I know the mechanism ... but Iäm wondering why I can serialize my class
with version 1.4.2 but not with the actual 1.5 ...
If it is really a bug i need a workaround....



 
Reply With Quote
 
John C. Bollinger
Guest
Posts: n/a
 
      02-15-2005
Andreas Beresko wrote:

>>Maybe. JTree implements Serializable, but whether you can serialize a
>>particular JTree instance depends also on all the other objects in the the
>>JTree's graph. If you have added a non-serializable object directly or
>>indirectly to the JTree's model, for instance, then you can expect to
>>receive NotSerializableExceptions when you try to serialize the tree.
>>Seeing DefaultMutableTreeNode.writeObject() in the stack trace makes me
>>think that this is what has happened.

>
>
> I know the mechanism ... but Iäm wondering why I can serialize my class
> with version 1.4.2 but not with the actual 1.5 ...
> If it is really a bug i need a workaround....


You cannot serialize your class in 1.4.2 either. You don't serialize
classes at all, only instances. This is why it makes sense to say that
a class is Serializable but one of its instances cannot be serialized.

If you want to understand why the problem has arisen then you're going
to have to dig deeper into your code. _Which_ DefaultMutableTreeNode(s)
causes the problem? What is its content? That's ultimately where the
problem is likely to reside. Without more information neither one of us
can do better than speculate.

--
John Bollinger
(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Serializing an object from HttpApplicationState Natan ASP .Net 5 09-27-2004 10:53 AM
Serializing classes from Web Services Russ ASP .Net 1 08-10-2004 01:33 PM
problem de-serializing a dataset MattB ASP .Net 0 04-27-2004 05:47 PM
serializing a class & performance -- advice? Jason Shohet ASP .Net 4 07-29-2003 06:47 PM
Serializing classes derived from dataset Aidan Glendye ASP .Net 1 07-28-2003 02:29 PM



Advertisments