Object (de)serialisation: class loaders
Following up my previous post on object serlialisation and deserialisation, a minor gotcha: Passing ‘null’ as the second parameter to JavaSerializer may throw ClassNotFoundException when reading your own custom classes back in.
So, pass to JavaSerializer a class loader you know can load your custom classes. For me, the easiest to use is the class loader which has already created one of my own objects, like so:
val js = new JavaSerializer(null, classOf[com.sdstrowes.simulator.RIB].getClassLoader())
The rest remains the same.