find a non-serializable class/object
I'm wondering if there's any way of tracking down the specific object that's causing a NotSerializableException? I have a fairly complex object that I'm trying to write to disk, and I keep getting this exception. I've checked all of my class files, and they all implement Serializable. If I could at least find out which object is failing, maybe I could figure out what's wrong.
Any thoughts appreciated.
thanks,
J.
Doesn't it say in the stack trace?
--
O
jbmaxwell wrote:
> I'm wondering if there's any way of tracking down the specific object
> that's causing a NotSerializableException? I have a fairly complex
> object that I'm trying to write to disk, and I keep getting this
> exception. I've checked all of my class files, and they all implement
> Serializable. If I could at least find out which object is failing,
> maybe I could figure out what's wrong.
>
> Any thoughts appreciated.
>
> thanks,
>
> J. _______________________________________________ java-dev mailing
>
No. All it shows in the trace, before it hits my "save" method is:
java.io.NotSerializableException: java.lang.Object
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1375)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1347)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
...which doesn't do me much good.
J.
Quote: owen wrote on Sun, 06 January 2008 21:36
----------------------------------------------------
> Doesn't it say in the stack trace?
>
> --
> O
>
> jbmaxwell wrote:
> > I'm wondering if there's any way of tracking down the specific object
> > that's causing a NotSerializableException? I have a fairly complex
> > object that I'm trying to write to disk, and I keep getting this
> > exception. I've checked all of my class files, and they all implement
> > Serializable. If I could at least find out which object is failing,
> > maybe I could figure out what's wrong.
> >
> > Any thoughts appreciated.
> >
> > thanks,
> >
> > J. _______________________________________________ java-dev mailing
> >
>
>
>
----------------------------------------------------
> java.io.NotSerializableException: java.lang.Object
Suggests that it's choking on trying to serialize an instance of
java.lang.Object. This seems unlikely, but it's possible that a class
somewhere in your object graph has a field declared as Object.
This could include built-in classes (like implementations of Reference,
for example). If you can find it, you could either skip serializing it,
by also declaring it transient, or work out way of serializing the thing.
Eclipse, or similar, should make it much easier to find the culprit, if
you're not already using it.
--
O
jbmaxwell wrote:
> No. All it shows in the trace, before it hits my "save" method is:
>
> java.io.NotSerializableException: java.lang.Object
> at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
> at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1375)
> at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1347)
> at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290)
> at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
> at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
>
> ...which doesn't do me much good.
>
> J.
>
>
>
Cheers, Owen.
Yes, I'm using Eclipse already. I'll look for a generic Object. I'm not sure where that would be, but I do have some vague recollection that I might have used an ArrayList to handle some subclassed objects... Not sure. Maybe that's where it's choking. I'll look into it.
I read somewhere that serialization is not great for persistence. But that's about all I've been using, so far. Any particular approaches I should read up on? What do you tend to use?
thanks again.
J.
Quote: owen wrote on Wed, 09 January 2008 19:48
----------------------------------------------------
>
> > java.io.NotSerializableException: java.lang.Object
>
> Suggests that it's choking on trying to serialize an instance of
> java.lang.Object. This seems unlikely, but it's possible that a class
> somewhere in your object graph has a field declared as Object.
>
> This could include built-in classes (like implementations of Reference,
> for example). If you can find it, you could either skip serializing it,
> by also declaring it transient, or work out way of serializing the thing.
>
> Eclipse, or similar, should make it much easier to find the culprit, if
> you're not already using it.
>
> --
> O
>
> jbmaxwell wrote:
> > No. All it shows in the trace, before it hits my "save" method is:
> >
> > java.io.NotSerializableException: java.lang.Object
> > at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
> > at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1375)
> > at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1347)
> > at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290)
> > at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
> > at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
> >
> > ...which doesn't do me much good.
> >
> > J.
> >
> >
> >
>
>
----------------------------------------------------