jerkson
jerkson copied to clipboard
ClassNotFound Exception when deserializing using parallel collection
List(json1, json2, ...).par.map(json => Json.parseFoo)
Can't find the Foo class (which is in a dependency) and throw ClassNotFound,
Work without .par
Got it working by overriding parse functions as:
override def parse[A : Manifest](input: String): A = {
val previous = Thread.currentThread.getContextClassLoader
try {
Thread.currentThread.setContextClassLoader(manifest[A].erasure.getClassLoader)
super.parseA
} finally {
Thread.currentThread.setContextClassLoader(previous)
}
}
Inpsired by: https://github.com/codahale/jerkson/issues/38