Java Networking : ObjectInput/OutputStream

Man of Honour
Joined
6 Aug 2006
Posts
1,497
Location
Stratford-upon-Avon
Hi All,

Been pulling my hair out and wondered if anyone here could give me an insight.

I have written a TCP socket based client and server for a java application and I am attempting to send serialized objects over the socket.

At one end I have :
Code:
ObjectOutputStream myOutStream = new ObjectOutputStream(Socket.getOutputStream());
myOutStream.writeObject(mySerializeableObject); 
myOutStream.flush();

At the other:

Code:
ObjectInputStream myInStream = new ObjectInputStream(Socket.getInputStream());

MySerializableObject newObject = (MySerializableObject ) myInStream.readObject();

When I run the application, and the client starts sending - the server simply throws "Class Not Found", and when checked the available bytes on the buffer never go above 0.

When I have tried sending ints or Strings over the socket they come through just fine - I am a bit stuck by this, and with no-one to ask at the weekend I wondered if anyone here could help! Sorry If i have missed anything.

Thanks,
Simon
 
I would paste all your code mate including your serealize object. we have no clue if your serealizable class is correct.

Plus which line of code does the error occur and can you please paste the whole error log too.
 
Hi, Thanks for the offer But I have solved it.

It occured because I wasn't thinking, I moved the shared serializable object into a package named "Shared" in both projects and manually set the SerializableVersionID() so they were equal, and now it works fine.

Thanks Again,

Regards,
Nomisf
 
J2SE, 2nd year project at Reading Uni - Yeah, its nice and fast to develop with, and I like the pleasing shiny results!
 
Back
Top Bottom