Why am I getting this error?
Serialization Problem
java.io.InvalidClassException: scala.reflect.ClassTypeManifest;
local class incompatible: stream classdesc serialVersionUID =
using intellij
Let me guess: you serialized (through java's built-in serialization) a class that contains a ClassManifest
(from whom ClassTypeManifest
is a subtype) to a file (or database), then upgraded your scala version, and are now attempting to deserialize that file, right?
Or you are sending a serialized object from one JVM process to another, and they run different versions of scala.
Well, don't do it.
The first reason is that ClassTypeManifest
declares no explicit serialVersionUID
field (see What is a serialVersionUID and why should I use it?), which clearly indicates that any change to the class might change the serialization format. You cannot really expect any backward compatibility in ClassTypeManifest
's serailized streams.
In addition, in scala 2.10 ClassManifest
is not even a class anymore: it's a mere alias to ClassTag
which is a significantly different class.
So really, don't expect to be able to serialize (using java's serialization) a ClassManifest
and read it back with another version of scala.
If you really need to do use java reflection, you might try to replace your ClassManifest
fields with java.lang.Class
fields (which are always safe to serialize/deserialize).
Otherwise, you could look into using other serialization libraries.