jerkson icon indicating copy to clipboard operation
jerkson copied to clipboard

ClassNotFound Exception when deserializing using parallel collection

Open aloiscochard opened this issue 12 years ago • 1 comments

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

aloiscochard avatar Jul 30 '12 09:07 aloiscochard

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

aloiscochard avatar Jul 30 '12 09:07 aloiscochard