[Spread-users] deserialization problem on unix?

Daniel Rall dlr at collab.net
Wed May 14 15:32:44 EDT 2003

On Wed, 14 May 2003, Rod Fleischer wrote:

> Hi,

Heya Rod.

> I'm having a problem with deserialization on a unix machine, in 
> particular linux (redhat 7.2, 8.0, 9.0) and solaris (2.8).  The exact 
> same code running on a windows xp machine works completely fine.  And 
> I'm positive that it's the same code, because the filesystem with the 
> code lives on a windows xp machine and is smbmounted onto the unix machines.
> The specific details are that I encapsulate a Serializable object in a 
> SpreadMessage and send it out.  The unix side will throw an exception 
> when it tries to deserialize the object during a call to 
> SpreadMessage.getObject().  This doesn't make sense to me.

The ClassNotFoundException error you're seeing is usually the result of the
necessary bytecodes defining the class which you're deserializing not being
found in the JVM's CLASSPATH at deserialization time.  From the example you
show below, this doesn't look like the case.  Even so, double-check (or
whatever n is at this point) your classpath argument to the VM.
> Included below is a trivial example which manifests the problem for me.
> A Foo object is created and sent out via the SpreadConnection.  A call 
> to receive() is then made for a message from another client, from which 
> a Foo object is then extracted from the SpreadMessage and its contents 
> printed.
> Running this test between a windows and a linux machine, the windows 
> side works flawlessly.  The linux side is able to send a message to it 
> successfully.  The linux side, however, throws a ClassNotFoundException 
> when it attempts to deserialize the Foo object.  This strikes me as 
> rather odd, seeing as how it's being run from the exact same filesystem, 
> using the exact same .class file, and it just instantiated a Foo object 
> on its own to send out, thus proving that it DOES know about class Foo.
> The output on the linux side is as follows:
> [charlie:~/workspace/scng][12:28pm]% /usr/java/bin/java -cp ./classes 
> com.sparta.network.spread.Foo
> Press enter------------------------------
> Sending: charlie.columbia.sparta.com
> spread.SpreadException: readObject(): java.lang.ClassNotFoundException: 
> com.sparta.network.spread.Foo
>          at spread.SpreadMessage.getObject(SpreadMessage.java:566)
>          at com.sparta.network.spread.Foo.main(Foo.java:62)
> I added a couple lines for a FileOutputStream to dump the Serializable 
> object out to a file when it's written to and read from the socket.  The 
> serialized object from the windows side is identical to what the spread 
> connection on the linux side received.  (verified with linux 'cmp' 
> command.)  The linux side cannot successfully deserialize the object.

How different are the JVM versions running on the Linux and WinXP sides?

More information about the Spread-users mailing list