Scala Play Framework


I am using
scalaVersion := “2.12.6”
“” % “play-json_2.11” % “2.7.2”

and in the code I am getting error while using the parse function

println("jsonObject " + Json.parse(aggregates))

Exception in thread “main” java.lang.NoClassDefFoundError: scala/Product$class
at play.api.libs.json.BigDecimalParseSettings.(JsonParserSettings.scala:19)
at play.api.libs.json.JsonParserSettings$.(JsonParserSettings.scala:70)
at play.api.libs.json.JsonParserSettings$.(JsonParserSettings.scala)
at play.api.libs.json.jackson.JacksonJson$.play$api$libs$json$jackson$JacksonJson$$mapper$lzycompute(JacksonJson.scala:244)
at play.api.libs.json.jackson.JacksonJson$.play$api$libs$json$jackson$JacksonJson$$mapper(JacksonJson.scala:244)
at play.api.libs.json.jackson.JacksonJson$.parseJsValue(JacksonJson.scala:255)
at play.api.libs.json.StaticBinding$.parseJsValue(StaticBinding.scala:16)
at play.api.libs.json.Json$.parse(Json.scala:171)
at CodecJsonExample$.delayedEndpoint$CodecJsonExample$1(EncodeJsonDefaultExample.scala:92)
at CodecJsonExample$delayedInit$body.apply(EncodeJsonDefaultExample.scala:55)
at scala.Function0.apply$mcV$sp(Function0.scala:34)
at scala.Function0.apply$mcV$sp$(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App.$anonfun$main$1$adapted(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:389)
at scala.App.main(App.scala:76)
at scala.App.main$(App.scala:74)
at CodecJsonExample$.main(EncodeJsonDefaultExample.scala:55)
at CodecJsonExample.main(EncodeJsonDefaultExample.scala)
Caused by: java.lang.ClassNotFoundException: scala.Product$class
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
… 19 more


Got it

“” %% “play-json” % “2.6.9” is compatinble with scalaVersion := “2.12.6”


You are trying to use Scala version 2.12.6 with Play-JSON for Scala version 2.11.x. Try using Play-JSON for Scala 2.12.x.

1 Like

You must use play-json_2.12 with Scala 2.12 ; this is a convention for Scala libraries, as Scala doesn’t guarantee binary compatibility between major releases.

In SBT, you can just specify "" %% "play-json" % "2.7.2" (with double %%) and SBT will add the correct suffix depending on the Scala version configured. This is why your second example works, not because of the different version of Play Json.

You can check out all versions of Play Json available for Scala 2.12 by searching for the play-json_2.12 artifact on Maven Central: ; this sort of thing can come in handy when you don’t know if a library has been released for a given version of Scala.

1 Like