Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

InvalidClassException while serializing

4 views
Skip to first unread message

Dave Rudolf

unread,
Dec 20, 2003, 4:08:52 PM12/20/03
to
Hi all,

I have a class that implements Serializable, but also inherits from an
abstract (and non-serializable) class. For some reason, when I try to write
it to an ObjectOutputStream, it gives the following exception (sorry about
the line wrapping):

java.io.InvalidClassException: texdist.util.array2d.ObjectArray2D; no valid
constructor
at java.io.ObjectStreamClass.<init>(ObjectStreamClass.java:375)
at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:249)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1010)
at
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1330)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1302)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1245)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
at
texdist.texture.morphogen.AbstractMorphogenLattice.cloneRaw(AbstractMorphoge
nLattice.java:108)
....


Can anyone tell me what it's complaining about? The top class two
constructors: one has a couple of int params, the other has no params and
just calls the two-int constructor with default values.

Dave


Sudsy

unread,
Dec 20, 2003, 4:25:37 PM12/20/03
to
Dave Rudolf wrote:
> Hi all,
>
> I have a class that implements Serializable, but also inherits from an
> abstract (and non-serializable) class. For some reason, when I try to write
> it to an ObjectOutputStream, it gives the following exception (sorry about
> the line wrapping):
<snip>

> Can anyone tell me what it's complaining about? The top class two
> constructors: one has a couple of int params, the other has no params and
> just calls the two-int constructor with default values.
>
> Dave

What about the subclass? If you specify any constructors at all then
Java won't build you the default, no-argument constructor. And it
looks like this is what's missing: the no-argument constructor.

Dave Rudolf

unread,
Dec 20, 2003, 5:07:23 PM12/20/03
to

"Sudsy" <bitbu...@hotmail.com> wrote in message
news:3FE4BE51...@hotmail.com...

Sorry, I mislead you in my last post. The subclass (which is also the only
class that is being serialized) has a the default constructor, but some of
the others up the hierarchy (that are not serializable) do not have a
default.


Sudsy

unread,
Dec 20, 2003, 5:14:58 PM12/20/03
to
Dave Rudolf wrote:
<snip>

> Sorry, I mislead you in my last post. The subclass (which is also the only
> class that is being serialized) has a the default constructor, but some of
> the others up the hierarchy (that are not serializable) do not have a
> default.

PLEASE READ THE JAVADOCS!
All the information you need is right there. I hate to waste bandwidth
answering questions when the answers are so readily available.

Follow this link:
<http://java.sun.com/j2se/1.4.2/docs/api/java/io/Serializable.html>

Start reading here:
"To allow subtypes of non-serializable classes to be serialized...

0 new messages