This discussion is archived
3 Replies Latest reply: Jun 13, 2010 4:08 AM by Kayaman RSS

Serialization problem - Transporting Custom Object

843790 Newbie
Currently Being Moderated
Could anyone help me with the following problem? I know what the problem is but I cannot understand why. I am using netbeans to create a client/server application. I have three packages within a project (1) "main package" from where the user can trigger either the client component or the server component. (2) "client core" package include all the files of the client (3) "server core" package include all the files of the server. In general I have 2 independent components one for the client and one for the server but under the same pack.

In both "client core" and "server core" packages I have a custom object called "USER.java" this is identical to both packages. I want to send a "USER" object over a socket from server to client. Now the problem, when I try to sent this object over the socket when the client receives it and tries to read the object e.g
 User test = (User) in.readObject();
I get the following error :

CoreServer.User cannot be cast to CoreClient.User
java.lang.ClassCastException: CoreServer.User cannot be cast to CoreClient.User


Thanks in advance. If you need more code I will post it. Thanks