[Spread-users] deserialization problem on unix?

Daniel Rall dlr at collab.net
Wed May 14 15:52:33 EDT 2003


On Wed, 14 May 2003, Rod Fleischer wrote:

> Daniel Rall wrote:
> > 
> > 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.
> >  
> 
> No, it doesn't seem to be the case since it's already instantiated that 
> class.

Right, but it's easy to have the definitions of the class differ between
hosts, so that the bytecodes on one side of the network connection are
slightly different than the bytecodes on the other side.  Since 
you mounted the same file system for use by both hosts, this seems unlikely 
(especially since you even diffed the serialized data).
 
> The classpath argument is correct, it only defines the ./classes 
> directory where the Foo class lives.  The spread.jar file is already 
> installed as a java extension (for ease of testing).
> 
> > How different are the JVM versions running on the Linux and WinXP sides?
> 
> XP    - 1.4.1_01
> Linux - 1.4.1_02

I'd try upping the XP version to _02 (assuming it's available).  I'd also 
try a smaller test case which takes Spread out of the picture.  Here's the 
code that's triggering the exception:

        public Object getObject() throws SpreadException
        {
                // The serialized object bytes.
                ///////////////////////////////
                ByteArrayInputStream objectBytes = new  ByteArrayInputStream(data);
                        
                // Setup the object input stream.
                /////////////////////////////////
                ObjectInputStream objectInput;
                try
                {
                        objectInput = new ObjectInputStream(objectBytes);
                }
                catch(IOException e)
                {
                        throw new SpreadException("ObjectInputStream(): " + e);
                }
         
                // De-serialize the object.
                ///////////////////////////
                Object object;
                try
                {
                        object = objectInput.readObject();
                }
                catch(ClassNotFoundException e)
                {
                        throw new SpreadException("readObject(): " + e);
                }
                catch(IOException e)
                {
                        throw new SpreadException("readObject(): " + e);
                }

"data" is a byte[] intialized by the SpreadMessage constructor.  See 
SpreadConnect.internal_receive() for the gory details.

For a narrower test case, I suggest open a TCP socket connection between 
your Linux and XP hosts, and writing a serialized 
com.sparta.network.spread.Foo object across it.  If you can deserialize on 
the Linux side, there may be a problem in that internal_receive() method of  
the SpreadConnection class.  If you still can't deserialize, the problem is 
somewhere in the JVM, library, envrionment, or OS level.

- Dan






More information about the Spread-users mailing list