Why am I getting this error?
Serialization Problem
java.io.InvalidClassException: scala.reflect.ClassTypeManifest;
local class incompatible: stream classdesc serialVersionUID =
using intellij
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Let me guess: you serialized (through java’s built-in serialization) a class that contains a
ClassManifest(from whomClassTypeManifestis 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
ClassTypeManifestdeclares no explicitserialVersionUIDfield (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 inClassTypeManifest‘s serailized streams.In addition, in scala 2.10
ClassManifestis not even a class anymore: it’s a mere alias toClassTagwhich is a significantly different class.So really, don’t expect to be able to serialize (using java’s serialization) a
ClassManifestand read it back with another version of scala.If you really need to do use java reflection, you might try to replace your
ClassManifestfields withjava.lang.Classfields (which are always safe to serialize/deserialize).Otherwise, you could look into using other serialization libraries.