On May 19, 2004, at 10:39 AM, Kenneth Sizer wrote:

I have a client and a server, connected via RMI. The client wishes to pass a "filter" to the server (see example below). Now, I was thinking/hoping that through the magic of RMI, my serializable implementation of the server's WidgetFilter interface would be sent over the wire and used by the server without issue. It seems I was wrong. The marshalling/classNotFound exceptions I get seem to indicate that the MyWidgetFilter class definition needs to exist in the server's VM a priori, but I could have sworn that dynamic class transport was one of RMI's big "cool feature" bullet points.

Hi Ken--

I'm not an RMI expert, but my product's remote server control/monitor design uses RMI to send objects back and forth, but as you noted, the .class file needs to exist ahead of time on the remote end. I believe the serialization code puts in a class definition tag at the head of the serialization, and then just sends the data values to the receiving end. On the receiving end the class tag is used to identify the class and the correct de-serialization code is used to reconstruct the class on the receiving end.

If you wanted to de-serialize a class for which no definition existed you'd have to serialize the class definition as well, and somehow dynamically use a class loader to make it available. This would quickly get fairly complicated compared to the basic scenario.

P.S. Don't forget to use serialver to isolate the serialization code from minor class changes.

___________________________________________________________________
michael at czeiszperger dot org
Chapel Hill, NC


_______________________________________________ Juglist mailing list [EMAIL PROTECTED] http://trijug.org/mailman/listinfo/juglist_trijug.org

Reply via email to