Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Exception with case classes nested within case classes #67
For a Play framework project I'm trying to parse nested case classes like so:
This breaks on the last line with an exception:
(at least when I run it within Play, see: https://groups.google.com/d/msg/play-framework/MKNPYOj9LBA/Ll6Fch98ZBkJ )
The issue seems to stem from: https://github.com/codahale/jerkson/blob/master/src/main/scala/com/codahale/jerkson/deser/CaseClassDeserializer.scala#L36 where it looks like it doesn't find the relevant constructor?
Try to use Jerkson from git master branch. For that you should use the following dependencies:
"org.codehaus.jackson" % "jackson-core-asl" % "1.9.8",
jackson-core-asl and jackson-mapper-asl are needed for Play Framework. Jerkson (master HEAD) uses Jackson 2.
The case classes are defined in "the outer space" (see the code snippet on https://groups.google.com/forum/#!msg/play-framework/MKNPYOj9LBA/Ll6Fch98ZBkJ%5B1-25%5D ).
Tried adding those dependencies, but despite adding:
to my plugins.sbt, sbt doesn't check repo.codahale.com which is very weird (see http://www.playframework.org/documentation/2.0/Repositories ).
Regardless though, there doesn't seem to be a 0.7.0-SNAPSHOT in that repo: http://repo.codahale.com/com/codahale/jerkson_2.9.1/
I have debugged this further. It seems to be an interaction issue between play and jerkson. On the first load in dev mode (from a fresh start) it works fine. If there is then a recompilation involving the nested classes, then it barfs on subsequent loads.
I suspect this is because the classes are effectively refreshed / updated, but jerkson keeps a static cache of the JavaTypes (see https://github.com/codahale/jerkson/blob/master/src/main/scala/com/codahale/jerkson/Types.scala#L9 ) and then presumably the matching done around https://github.com/codahale/jerkson/blob/master/src/main/scala/com/codahale/jerkson/deser/CaseClassDeserializer.scala#L21 fails, but I'm not sure.
If that is the case, then a potential fix could be to clear the Jerkson Types.cachedTypes on each reload in development. However, Types is private[jerkson] and Types.cachedTypes is private, so this is a little tricky to do.
Haven't found a workaround - right now I have to restart the dev server on each change to pretty much any part of the code. :(
Minor additional points: