InvalidClassException while serializing

D

Dave Rudolf

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
 
S

Sudsy

Dave said:
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):
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.
 
D

Dave Rudolf

Sudsy said:
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.

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.
 
S

Sudsy

Dave Rudolf wrote:
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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top