Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   InvalidClassException question (http://www.velocityreviews.com/forums/t134098-invalidclassexception-question.html)

Aidan 06-04-2004 02:16 PM

InvalidClassException question
 
According to the docs, this is exception is thrown:

"when the Serialization runtime detects one of the following problems
with a Class.

* The serial version of the class does not match that of the class
descriptor read from the stream
* The class contains unknown datatypes
* The class does not have an accessible no-arg constructor "


Can someone explain to me what "The class contains unknown datatypes" means?

I'm getting this exception, and can't figure out why. Both sides (local
and remote) use the same class, in the same jar, and run in the same JVM
(which rules out the 1st reason). The class does have a public no-arg
constructor (which rules out the 3rd reason), and I've tried encoding
the serialVersionUID directly in the class just to make sure.



Aidan

Derek Chen-Becker 06-04-2004 02:50 PM

Re: InvalidClassException question
 
Aidan wrote:
> According to the docs, this is exception is thrown:
>
> "when the Serialization runtime detects one of the following problems
> with a Class.
>
> * The serial version of the class does not match that of the class
> descriptor read from the stream
> * The class contains unknown datatypes
> * The class does not have an accessible no-arg constructor "
>
>
> Can someone explain to me what "The class contains unknown datatypes"
> means?
>
> I'm getting this exception, and can't figure out why. Both sides (local
> and remote) use the same class, in the same jar, and run in the same JVM
> (which rules out the 1st reason). The class does have a public no-arg
> constructor (which rules out the 3rd reason), and I've tried encoding
> the serialVersionUID directly in the class just to make sure.
>
>
>
> Aidan


Problem two means that if any of a classes' members are non-primitive,
non-serializable objects, then you can't serialize an instance of that
class.

Derek

Aidan 06-04-2004 05:28 PM

Re: InvalidClassException question
 
Derek Chen-Becker wrote:

> Aidan wrote:
>
>> According to the docs, this is exception is thrown:
>>
>> "when the Serialization runtime detects one of the following problems
>> with a Class.
>>
>> * The serial version of the class does not match that of the class
>> descriptor read from the stream
>> * The class contains unknown datatypes
>> * The class does not have an accessible no-arg constructor "
>>
>>
>> Can someone explain to me what "The class contains unknown datatypes"
>> means?
>>
>> I'm getting this exception, and can't figure out why. Both sides
>> (local and remote) use the same class, in the same jar, and run in the
>> same JVM (which rules out the 1st reason). The class does have a
>> public no-arg constructor (which rules out the 3rd reason), and I've
>> tried encoding the serialVersionUID directly in the class just to make
>> sure.
>>
>>
>>
>> Aidan

>
>
> Problem two means that if any of a classes' members are non-primitive,
> non-serializable objects, then you can't serialize an instance of that
> class.
>
> Derek


Thanks Derek - it actually turned out to be an instance of the 1st
problem, since some code had been changed to serialize object instances
to a file. doh!

Roedy Green 06-04-2004 06:26 PM

Re: InvalidClassException question
 
On Fri, 04 Jun 2004 14:16:39 GMT, Aidan <aidan@nowhere.com> wrote or
quoted :

>Can someone explain to me what "The class contains unknown datatypes" means?


see
http://mindprod.com/jgloss/errormess...CLASSEXCEPTION

That sounded like one of Sun's better explanations. Mine won't be that
much more elucidating, but at least it is longer.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.

Roedy Green 06-04-2004 06:27 PM

Re: InvalidClassException question
 
On Fri, 04 Jun 2004 14:16:39 GMT, Aidan <aidan@nowhere.com> wrote or
quoted :

>
>I'm getting this exception, and can't figure out why. Both sides (local
>and remote) use the same class, in the same jar, and run in the same JVM
>(which rules out the 1st reason). The class does have a public no-arg
>constructor (which rules out the 3rd reason), and I've tried encoding
>the serialVersionUID directly in the class just to make sure.


Are you getting the problem on write or read?

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.

Roedy Green 06-04-2004 06:29 PM

Re: InvalidClassException question
 
On Fri, 04 Jun 2004 14:16:39 GMT, Aidan <aidan@nowhere.com> wrote or
quoted :

>I'm getting this exception, and can't figure out why. Both sides (local
>and remote) use the same class, in the same jar, and run in the same JVM
>(which rules out the 1st reason). The class does have a public no-arg
>constructor (which rules out the 3rd reason), and I've tried encoding
>the serialVersionUID directly in the class just to make sure.


have you freshly written these objects with your latest class
definition? Have you utterly proved to yourself you are using
identical code on both ends? You might write an Integer( version ) at
the head of both streams just to be sure.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.

Aidan 06-04-2004 07:49 PM

Re: InvalidClassException question
 
Roedy Green wrote:


>
> have you freshly written these objects with your latest class
> definition?


That was exactly the problem Roedy.


All times are GMT. The time now is 07:29 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57