Getting MissingRequirementError after moving classes to another package

226 views Asked by At

So I was trying to organize my packages a bit better, and after moving some classes to another package my code now gives me this exception:

Exception in thread "main" scala.reflect.internal.MissingRequirementError: class Track not found.
at scala.reflect.internal.MissingRequirementError$.signal(MissingRequirementError.scala:16)
at scala.reflect.internal.MissingRequirementError$.notFound(MissingRequirementError.scala:17)
at scala.reflect.internal.Mirrors$RootsBase.ensureClassSymbol(Mirrors.scala:90)
at scala.reflect.internal.Mirrors$RootsBase.staticClass(Mirrors.scala:119)
at scala.reflect.internal.Mirrors$RootsBase.staticClass(Mirrors.scala:21)
at scala.pickling.internal.package$.typeFromString(package.scala:61)
at scala.pickling.internal.package$$anonfun$2.apply(package.scala:63)
at scala.pickling.internal.package$$anonfun$2.apply(package.scala:63)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at scala.collection.immutable.List.foreach(List.scala:318)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
at scala.collection.AbstractTraversable.map(Traversable.scala:105)
at scala.pickling.internal.package$.typeFromString(package.scala:63)
at scala.pickling.FastTypeTag$.apply(FastTags.scala:57)
at scala.pickling.json.JSONPickleReader$$anonfun$beginEntry$2.apply(JSONPickleFormat.scala:204)
at scala.pickling.json.JSONPickleReader$$anonfun$beginEntry$2.apply(JSONPickleFormat.scala:193)
at scala.pickling.PickleTools$class.withHints(Tools.scala:425)
at scala.pickling.json.JSONPickleReader.withHints(JSONPickleFormat.scala:159)
at scala.pickling.json.JSONPickleReader.beginEntry(JSONPickleFormat.scala:193)
at scala.pickling.json.JSONPickleReader.beginEntryNoTag(JSONPickleFormat.scala:192)
at BillboardsHot100.deserializeTrackList(Billboards.scala:60)
at BillboardsHot100.checkForChanges(Billboards.scala:31)
at Main$.main(Main.scala:7)
at Main.main(Main.scala)

If I leave everything in the same package or declare these classes in the same file, it works fine.

Can someone enlighten me on how to fix this?

SOLVED: In case has this problem too, the problem was in how Pickling serializes. In the json, there's a field 'tpe' for type, and it changed from

"tpe": "Track"

to

"tpe": "com.new.package.path.Track"

which was the new package (not really my package name). Hope this example can help someone else out in the future.

1

There are 1 answers

2
Robin Green On BEST ANSWER

Maybe you are trying to read some old data that is pickled under the old class name. Obviously this won't work.

You need to temporarily serialize it in some alternative way, I think, in order to get around this problem.