Forums Register Login

Unserializable error

+Pie Number of slices to send: Send
Hi,

I have a problem with object serialization.

I have a remote object A which contains a vector. It implements remote interface C, which contains a single method that returns this vector to the client side. Class A also has a setVector method that allows a server side class B to update the vector content. So the client always gets a fresh copy of the vector modified by class B when it invokes the remote call.

Everthing goes well before class B calls the setVector method. However, after class B calls setVector method to update the vector, an exception is thrown when the client invoke the remote call. This exception says class B cannot be serialized. But I only return the vector that is modified by class B to the client side, not any instance of class B.

What is wrong with it? It works fine with CORBA. But why Java RMI doesnt like it?

Thanks.
+Pie Number of slices to send: Send
Post JUST the relavent portions of the classes so we can see what you're talking about.
+Pie Number of slices to send: Send
For the vector being serialized, all it's elements must be too.
So if the vector contains a non serializable object, the vector can not be serialized.

Your problem seems to be that your vector constains instances of B.

As a aside note, passing o returning Collections in remote method is not a good practice.

Regards
+Pie Number of slices to send: Send
 

passing o returning Collections in remote method is not a good practice.


Absolutely right! Send arrays - the Collections API has great methods for converting between arrays and Java collections.
Bill
He's my best friend. Not yours. Mine. You can have this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 732 times.
Similar Threads
ClassCastException after RemoteCall
Does Synchronisazion prevent from readOnly-Operations?
how to get Clients CPU information on Server using Java RMI
ClientData problem
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 01:02:08.