Question

I am building a Play! Framework application using Play! 2.2.1, sbt 0.13.0, and my local version of scala is 2.10.3.

I have encountered a serialVersionUID problem when deserializing a particular file that I inherited from coworkers for working on this project (I have no idea who created this serialized file (or when)).

My error message, when building in Play!:

Caused by: java.io.InvalidClassException: scala.collection.mutable.WrappedArray$ofRef; local class incompatible: stream classdesc serialVersionUID = 8184381945838716286, local class serialVersionUID = -8707880168089396949

After much searching, I found this patch that is supposed to fix the bug SI-5046:

https://issues.scala-lang.org/browse/SI-5046

I downloaded the scala source code from github for branch 2.10.x and I applied the patch to WrappedArray.scala here: scala/src/library/scala/collection/mutable/WrappedArray.scala

What do I do with this modified source code so that I can use it in my Play! application?

* EDIT #1:

I followed the links from @Alexey Romanov

I'm still getting an error message about WrappedArray$ofRef when I compile Play, though now it is a different error message. Here is what I did:

I rebuilt the scala distribution using ant, using:

ant build

ant partialdist

Then in Play! I specified the scala version to use for SBT and plugins by adding the following to my Build.scala file:

scalaVersion := "2.10.3" autoScalaLibrary := false scalaHome := Some(file("/path_to_my_rebuilt_scala_distribution"))

Now my error message is:

Caused by: java.io.InvalidClassException: scala.collection.mutable.WrappedArray$ofRef; incompatible types for field bitmap$0

EDIT #2:

I'm moving down the Scala versions and when I got to 2.9.2, the error about WrappedArray$ofRef was fixed by applying the patch. Now I am getting another serialization error for a different class:

java.io.InvalidClassException: scala.Symbol; local class incompatible: stream classdesc serialVersionUID = -3681772905693662441, local class serialVersionUID = 7747205442425187939

I will move down to Scala 2.9.1 and see if I can get to the contents of the file with that version.

* EDIT #3:

In scala version 2.9.1-1, I get a different serialization error: java.io.InvalidClassException: scala.Tuple2; local class incompatible: stream classdesc serialVersionUID = 3990034604647285925, local class serialVersionUID = 5867822941721784448

No idea what to try next.. keep going down scala versions, or are there other suggestions?

Was it helpful?

Solution

To use a local Scala installation for building a project define scalaHome:

scalaHome := Some(file("/path/to/scala/home/"))

Also see How can I change version of Scala that is used by Play, SBT and its plugins? if you end up having to rebuild Play as well.

EDIT: I actually looked at the bug description. It looks like the patch will allow serializing/deserializing WrappedArray created by two different Scala versions which both include this patch. Since

(I have no idea who created this serialized file (or when))

it probably won't work for you. And judging from the new error message, it may be that the version of Scala it was serialized with simply didn't include the fields 2.10.3 does and it's impossible to deserialize. My best suggestion is to try deserializing with different Scala versions going down (probably not 2.10.*, since they are binary compatible) and see which one works.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top