Are both the client and server using the same code? Is the object
being sent serialized from a prior version of the class?
When an object is serialized, if it does not contain a
serialVersionUID, then a default one is generated. That default
serialVersionUID is based on the variables, methods, name, package and
other information of the class. When the object is deserialized, it
is checked against the current serialVersionUID. If the code on the
deserializing side does not contain a serialVersionUID, a default one
is generated (again based on methods, variables, etc..) for that side
too.
If neither have serialVersionUIDs, and one version of the class (from
a client) is sent to another (the server), then the server can't
deserialize it. Similarly, just adding a random serialVersionUID into
the server won't fix that. To be compatible with prior versions of
the class, you need to set the serialVersionUID to be the same as what
the default version used to be.
Sam
On Nov 29, 2007 7:07 PM, Adrian Bartholomew <email@hidden> wrote:
> Hmmmmm, promising reply.
>
>
> Okay
> Make sure you add an explicit public static final long
> serialVersionUID to your class - for now set it to 1L;
>
> I did. It still doesn't work. I tried 1L and 9999999999999999999L.
>
>
>
> Then try again, if you're using RMI or jini, ensure you update your
> codebase with this class,
>
> What does "update your codebase" mean?
>
> if you're not and you're using sockets or
> similar, make sure the client has the same copy of the class.
>
> I'm not using sockets.
>
>
>
> If you have a problem you should see that the stream classdesc version
> is 1L because the server is running with the class that has the
> explicit serialVersionUID value, and the client isn't which means
> either you're running an older version of the class (probably a reason
> why the serialVersionUIDs are different to start with)
>
> Actually its the classdesc that's not taking my hard coded value :
> java.io.InvalidClassException: com.[packagename].shared.model.User; local
> class incompatible: stream classdesc serialVersionUID =
> -2102598104259217202, local class serialVersionUID = 1
>
>
>
>
> or you have an
> old version on your classpath that you don't know about
>
> How do I check this? I'm sorry, I am inexperienced.
>
> Thanks Calum
>
> -- Adrian
>
>
> On 29/11/2007, Adrian Bartholomew <email@hidden> wrote:
> Thank you so much for your prompt reply.
> I guess that I was not as concise as I thought I was.
>
> i used x and y just to portray that they were different values.
> y is the value of my hard coded value if I implemented static int
> serialVersionUID = y, an arbitrary value if I did not.
>
> I am using Java1.5 on both client and server.
> I use Leopard.
> I did not include this information because, as I stated, it worked
> perfectly up until i added the ArrayList of UserStatus.
> Therefore, the Serialization of User was version safe.
>
> The error is occurring on the server at:
> event = (RemoteEvent) input.readObject();
>
> -- A
>
>
> On Thursday29,Nov 2007, at 5:29 PM, Greg Guerin wrote:
>
>
> Adrian Bartholomew wrote:
>
>
>
> java.io.InvalidClassException: User; local class incompatible: stream
>
> classdesc serialVersionUID = xxxxxxxxxxxxx, local class
>
> serialVersionUID = yyyyyyyyyyyy
>
>
>
> Exactly what values are xxxxxxxxxxxxx and yyyyyyyyyyyy?
>
>
>
> What version of Java and OS is this on, for each of client and server?
>
>
>
> And is the exception thrown on the client or on the server?
>
>
>
> -- GG
>
>
>
>
>
> _______________________________________________
>
> Do not post admin requests to the list. They will be ignored.
>
> Java-dev mailing list (email@hidden)
>
> Help/Unsubscribe/Update your Subscription:
>
> http://lists.apple.com/mailman/options/java-dev/email@hidden
>
>
>
> This email sent to email@hidden
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Java-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/java-dev/email@hidden
>
> This email sent to email@hidden
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Java-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/java-dev/email@hidden
>
> This email sent to email@hidden
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Java-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/java-dev/email@hidden
>
> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden
This email sent to email@hidden