I am new to RMI. From the java docs i found that InvalidClassException is thrown when serial version is not matched among local and remote file. But i wrote a dummy class which always throws a InvalidClassException even though statically created serialVersionUID
package com.sac.serialization;
import java.io.*;
import java.util.*;
class ClassA // non-serializable parent class
{
String parentname;
// absence of no-arg constructor
ClassA(String name) {
parentname = name;
}
}
class ClassB extends ClassA implements Serializable {
private static final long serialVersionUID = 1L;
ClassB(String name) {
super(name);
}
}
public class ClassC {
public static void main(String args[]) {
ClassB c1 = new ClassB("Sachin");
try {
ObjectOutputStream out = new ObjectOutputStream(
new FileOutputStream("employee.dat"));
out.writeObject(c1);
out.close();
ObjectInputStream in = new ObjectInputStream(
new FileInputStream("employee.dat"));
ClassA p = (ClassB) in.readObject();
in.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Can some body help me find the root cause?