Deserialization Problem on Linux with Custom ClassLoader
I am writing a Vector object to a file like this:
ObjectOutputStream out =new ObjectOutputStream(new FileOutputStream(file));
out.writeObject(vector);
out.close();
To read it back using a custom ClassLoader I have
ObjectInputStream in =new ObjectInputStream(new FileInputStream(file)){
protected Class<?> resolveClass(ObjectStreamClass desc)throws ClassNotFoundException{
return classLoader.loadClass(desc.getName());
}
};
vector = (Vector<T>)in.readObject();
in.close();
This works fine on Windows, but not on Linux. The problem is that my custom ClassLoader has to find a class named "[Ljava.lang.Object;" which is, as far as I have found out, usually handled by the default ClassLoader of the JVM. The ClassNotFoundException contains this stack trace:
java.lang.ClassNotFoundException:class'[Ljava.lang.Object;' not found by FileClassLoader.
at ch.ethz.dcg.plugin.classloader.FileClassLoader.findClass(FileClassLoader.java:140)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at ch.ethz.dcg.util.LazyBackupedVector$1.resolveClass(LazyBackupedVector.java:141)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readArray(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at ch.ethz.dcg.util.LazyBackupedVector.loadFile(LazyBackupedVector.java:145)
Can anyone explain the behavior to me? Am I doing something wrong? Thanks!

