When I try to cast an object of NetworkObject class (a class I have created )that has arrived at a server from a client I get an error -
java.lang.ClassNotFoundException... client.NetworkObject

I have the class in a Server package, but why does it specify that client.NetworkObject is not found, and how can I solve this?

I cut and pasted the NetworkObject from the client package to the server package

Communication is client to server.

Is this to do with the packages i have (client and server)

Thanks

you'll have to make sure the class is available on both ends of the connection.

I do hope you have properly serialised it as otherwise it's unlikely to work whatever you do.

Another point to remember is subtle, so only look into this of all else fails

Two classes are regarded as distinct if they come from different classloaders. Even if they are the same file or match byte for byte.

(This is why I treat anything regarding classloaders the way I would treat nuclear waste)

When I try to cast an object of NetworkObject class (a class I have created )that has arrived at a server from a client I get an error -
java.lang.ClassNotFoundException... client.NetworkObject

I have the class in a Server package, but why does it specify that client.NetworkObject is not found, and how can I solve this?

I cut and pasted the NetworkObject from the client package to the server package

Communication is client to server.

Is this to do with the packages i have (client and server)

Thanks

if the object was properly serialised over the connection that wouldn't matter though, the classloader information would have been stripped.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.