Error when using play-json 2.7.1 instead of 2.6.13

181 views
Skip to first unread message

Martin Burger

unread,
Feb 25, 2019, 9:26:04 AM2/25/19
to ReactiveMongo - http://reactivemongo.org
Hello:

I am currently using (amongst other libraries):
  • Play 2.7.0
  • play2-reactivemongo 0.16.2-play27
  • play-json 2.6.13
  • play-json-joda 2.6.13
  • joda-time 2.10.1
  • joda-convert 2.2.0
  • Scala 2.12.8
  • sbt 1.2.8
I would like to update play-json and play-json-joda to latest version 2.7.1. However, as soon as I change from version 2.6.13 to version 2.7.1 in build.sbt, I get the following error:

Uncaught error from thread [application-akka.actor.default-dispatcher-3]: scala/collection/compat/Factory$, shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[application]
java
.lang.NoClassDefFoundError: scala/collection/compat/Factory$
 at reactivemongo
.play.json.JSONSerializationPack$Decoder$.children(JSONSerializationPack.scala:243)
 at reactivemongo
.play.json.JSONSerializationPack$Decoder$.children(JSONSerializationPack.scala:219)
 at reactivemongo
.api.commands.UpdateCommand$.$anonfun$reader$1(UpdateCommand.scala:119)
 at reactivemongo
.api.commands.CommandCodecs$.$anonfun$dealingWithGenericCommandErrorsReader$1(CommandCodecs.scala:19)
 at reactivemongo
.play.json.JSONSerializationPack$.$anonfun$reader$1(JSONSerializationPack.scala:157)
 at play
.api.libs.json.Reads$$anon$6.reads(Reads.scala:195)
 at reactivemongo
.play.json.JSONSerializationPack$.deserialize(JSONSerializationPack.scala:59)
 at reactivemongo
.play.json.JSONSerializationPack$.deserialize(JSONSerializationPack.scala:33)
 at reactivemongo
.api.SerializationPack.readAndDeserialize(SerializationPack.scala:36)
 at reactivemongo
.api.SerializationPack.readAndDeserialize$(SerializationPack.scala:35)
 at reactivemongo
.play.json.JSONSerializationPack$.readAndDeserialize(JSONSerializationPack.scala:33)
 at reactivemongo
.api.SerializationPack.readAndDeserialize(SerializationPack.scala:40)
 at reactivemongo
.api.SerializationPack.readAndDeserialize$(SerializationPack.scala:38)
 at reactivemongo
.play.json.JSONSerializationPack$.readAndDeserialize(JSONSerializationPack.scala:33)
 at reactivemongo
.api.commands.Command$$anon$2.$anonfun$one$5(commands.scala:147)
 at scala
.concurrent.Future$.$anonfun$apply$1(Future.scala:658)
 at scala
.util.Success.$anonfun$map$1(Try.scala:255)
 at scala
.util.Success.map(Try.scala:213)
 at scala
.concurrent.Future.$anonfun$map$1(Future.scala:292)
 at scala
.concurrent.impl.Promise.liftedTree1$1(Promise.scala:33)
 at scala
.concurrent.impl.Promise.$anonfun$transform$1(Promise.scala:33)
 at scala
.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
 at akka
.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
 at akka
.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:91)
 at scala
.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
 at scala
.concurrent.BlockContext$.withBlockContext(BlockContext.scala:85)
 at akka
.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:91)
 at akka
.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40)
 at akka
.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:44)
 at akka
.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
 at akka
.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
 at akka
.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
 at akka
.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: java.lang.ClassNotFoundException: scala.collection.compat.Factory$
 at java
.net.URLClassLoader.findClass(URLClassLoader.java:381)
 at java
.lang.ClassLoader.loadClass(ClassLoader.java:424)
 at java
.lang.ClassLoader.loadClass(ClassLoader.java:357)
 
... 33 more

Is above error caused by any incompatibility between play-json 2.7.1 and ReactiveMongo?

Best wishes,

Martin

br...@surchx.com

unread,
Mar 1, 2019, 8:46:39 AM3/1/19
to ReactiveMongo - http://reactivemongo.org
Not sure if there is a way to +1 or follow this but I am having this same issue.  I suspect it is related to joda datetime serialization.   I have the same dependencies as Martin listed (except for a couple minor joda version differences)

Appears I can *read* ok however, on the first insert, it fails with the same stack.

Thanks in advance. 

Brad

Cédric Chantepie

unread,
Mar 2, 2019, 1:51:09 PM3/2/19
to ReactiveMongo - http://reactivemongo.org
Make sure there is no dependency for different Scala versions, otherwise paste there the result of SBT dependency:tree

br...@surchx.com

unread,
Mar 4, 2019, 11:16:43 AM3/4/19
to ReactiveMongo - http://reactivemongo.org
 I am attaching my dependency tree hoping that you can grep something useful out of it.  I tried to remove and update some dependencies but I am still getting this CNF exception.   If you have any additional thoughts on what to look for in my dependency tree, I will try to do some additional grepping too.

Thanks for the response.


xx

Cédric Chantepie

unread,
Mar 4, 2019, 1:58:23 PM3/4/19
to ReactiveMongo - http://reactivemongo.org
You can filter the subtree of reactivemongo deps.

bor...@gmail.com

unread,
Mar 5, 2019, 1:11:09 PM3/5/19
to ReactiveMongo - http://reactivemongo.org
Have the same issue. 

Caused by: java.lang.ClassNotFoundException: scala.collection.compat.Factory$
        at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at reactivemongo.play.json.JSONSerializationPack$Decoder$.children(JSONSerializationPack.scala:243)
        at reactivemongo.play.json.JSONSerializationPack$Decoder$.children(JSONSerializationPack.scala:219)
        at reactivemongo.api.commands.UpdateCommand$.$anonfun$reader$1(UpdateCommand.scala:119)
        at reactivemongo.api.commands.CommandCodecs$.$anonfun$dealingWithGenericCommandErrorsReader$1(CommandCodecs.scala:19)
        at reactivemongo.play.json.JSONSerializationPack$.$anonfun$reader$1(JSONSerializationPack.scala:157)
        at play.api.libs.json.Reads$$anon$6.reads(Reads.scala:195)


I don't (intentionally) have any dependency on other scala versions.  (i use 2.12.8 with sbt 1.2.8)

bor...@gmail.com

unread,
Mar 5, 2019, 2:03:13 PM3/5/19
to ReactiveMongo - http://reactivemongo.org
Forgot to mention - I have the same dependencies.  In particular,
"net.codingwell"                %% "scala-guice"          % "4.2.3",
"org.reactivemongo"             %% "play2-reactivemongo"  % "0.16.2-play27",
"com.typesafe.play"             %% "play-json-joda"       % "2.6.13",

Trying to upgrade play-json-joda to 2.7.1 triggers the above exception (only on write, not on read).

bor...@gmail.com

unread,
Mar 5, 2019, 2:12:57 PM3/5/19
to ReactiveMongo - http://reactivemongo.org
I just ran another test which showed that 

"net.codingwell"                %% "scala-guice"          % "4.2.3",
"org.reactivemongo"             %% "play2-reactivemongo"  % "0.16.2-play26",
"com.typesafe.play"             %% "play-json-joda"       % "2.7.1",

with Play 2.6.21 works fine.

I will try to create a minimal Play project that reproduces the problem.

bor...@gmail.com

unread,
Mar 5, 2019, 7:08:47 PM3/5/19
to ReactiveMongo - http://reactivemongo.org
Here's a project that showcases the problem, containing minimal dependencies.


@Cédric: do you think this might be a problem with play2-reactivemongo, or you think it's something external?  I can submit a bug report if you want.

Cédric Chantepie

unread,
Mar 6, 2019, 1:20:46 PM3/6/19
to ReactiveMongo - http://reactivemongo.org
No issue without qualification

bor...@gmail.com

unread,
Mar 6, 2019, 1:37:08 PM3/6/19
to ReactiveMongo - http://reactivemongo.org
Hello Cédric,

What kind of information are you looking for?

I tried to identify (by looking at code) where the problem lies, but I wasn't able to figure that out (was hoping I could fix it myself and submit a PR). 
I was able to re-create the problem in a sample (minimal) project that I shared on Github in the hope that you might have some time to take a look and see if it triggers some "A-HA" moment as to what might be wrong and where.

The README file in the sample project I shared describes the problem and the (interesting) situation where depending on the combination of dependency versions, things will work... so it's hard to pin-point the problem in any one particular dependency version.  What's more likely is an incompatibility that was created when trying to use the latest versions of these dependencies.

Please let me know how I can help figure this out.

Thanks,
Boris

On Wednesday, March 6, 2019 at 12:20:46 PM UTC-6, Cédric Chantepie wrote:
No issue without qualification

br...@surchx.com

unread,
Mar 8, 2019, 11:06:45 AM3/8/19
to ReactiveMongo - http://reactivemongo.org

FWIW, I found two projects that referenced this exception which seemed to lead back to a play-json PR "Replace scala-collection-compat with ScalaCollectionCompat"


In my dependencies, I have numerous "com.typesafe.play:play-json_2.12:2.7.0 (evicted by: 2.7.1)" lines.
It appears that play:2.7.0 still references play-json_2.12:2.7.0.  So perhaps we have to wait for a play:2.7.1.

The projects I have seen which might be effecting my case are (I removed joda and started using java.time)
"com.pauldijou" %% "jwt-play-json" % "2.1.0"
"com.beachape" %% "enumeratum-play" % "1.5.16"

Anyway, I don't know how to proceed other than to wait.  It appears to be with serialization which reactivemongo.play.json of course relies on.

Cédric Chantepie

unread,
Mar 9, 2019, 6:49:14 AM3/9/19
to ReactiveMongo - http://reactivemongo.org
You have to fix to redondant dependency in your build, either by adding exclusion rules or updating the dependencies that themselves pull Play-JSON transitively.

brad...@surchx.com

unread,
Mar 10, 2019, 9:03:39 PM3/10/19
to ReactiveMongo - http://reactivemongo.org

I have tried to reduce any transitive dependencies and done some excludeAll lines which reference play_json.   Doing that on dependencies outside of reactivemongo don't seem to effect anything.

I noticed in the provided dependencies of reactivemongo-play-json, it still references play-json.2.12:2.7.0 (which is evidently problematic).   So I thought I would try to build locally and see what happens.  Was looking at this information from here... https://mvnrepository.com/artifact/org.reactivemongo/reactivemongo-play-json_2.12/0.16.3-play27

I cloned reactivemongo-play-json locally and published 0.17.0-SNAPSHOT.  When I run with the SNAPSHOT version, everything works just fine.  When I run with the 0.16.3-play27 version it fails with the exception(s) referenced in this thread.  

// "org.reactivemongo" %% "reactivemongo-play-json" % "0.16.3-play27",
"org.reactivemongo" %% "reactivemongo-play-json" % "0.17.0-SNAPSHOT",
"org.reactivemongo" %% "play2-reactivemongo" % "0.16.3-play27",
"org.reactivemongo" %% "reactivemongo-akkastream" % "0.16.3",


I would love to help out and provide a PR for something but I'm a bit lost on what exactly is the issue.  

brad...@surchx.com

unread,
Mar 10, 2019, 10:49:28 PM3/10/19
to ReactiveMongo - http://reactivemongo.org

As possibly one helpful addition, it seems that it's the reactivemongo-play-json module which is compiled against the buggy play-json:2.7.0.  I can choose the play2-reactivemongo dependency as 0.16.3-play27 just not reactivemongo-play-json...  With the following two dependencies, mine "works"

"org.reactivemongo" %% "play2-reactivemongo" % "0.16.3-play27" exclude("org.reactivemongo", "reactivemongo-play-json_2.12"),
"org.reactivemongo" %% "reactivemongo-play-json" % "0.16.3-play26" exclude("org.reactivemongo", "play2-reactivemongo"),

Cédric Chantepie

unread,
Mar 11, 2019, 2:03:27 PM3/11/19
to ReactiveMongo - http://reactivemongo.org
If the dependency play2-reactivemongo is specified, the dependency to reactivemongo-play-json should not also be specified, as pull by the play2-reactivemongo (and can be error prone considering versions).

Then the reactivemongo-play-json should not pull itself play-json dependency, as this transitive dependency is scoped as Provided. It rather use any version of play-json provided by the build, as long as it is API compatible, that's to say a 2.7.x .

br...@surchx.com

unread,
Mar 11, 2019, 3:48:16 PM3/11/19
to ReactiveMongo - http://reactivemongo.org
That all make sense and I have since removed the reactive-play-json since it'll be provided.

However, I'm still "broken" as the reactive-play-json transitive dependency is still one that is not working for me because of the play-json:2.7.0 outdated dependency it used for compilation.  I have tried numerous ways to do exclusions and looking at the dependencyTree, it appears that is working.  But I still get the fatal exceptions.

tried excluding from play2-reactivemongo just to make sure... I have no play-json_2.12:2.7.0 dependencies showing up in dependencyTree.
"org.reactivemongo" %% "play2-reactivemongo" % "0.16.3-play27" excludeAll(
ExclusionRule(organization = "com.typesafe.play", "play-json"),
ExclusionRule(organization = "com.typesafe.play", "play-json_2.12")
),


Still getting these exceptions...
Caused by: java.lang.ClassNotFoundException: scala.collection.compat.Factory$
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at reactivemongo.play.json.JSONSerializationPack$Decoder$.children(JSONSerializationPack.scala:243)
    at reactivemongo.play.json.JSONSerializationPack$Decoder$.children(JSONSerializationPack.scala:219)
    at reactivemongo.api.commands.CommandCodecs$.$anonfun$defaultWriteResultReader$1(CommandCodecs.scala:36)

    at reactivemongo.api.commands.CommandCodecs$.$anonfun$dealingWithGenericCommandErrorsReader$1(CommandCodecs.scala:19)
    at reactivemongo.play.json.JSONSerializationPack$.$anonfun$reader$1(JSONSerializationPack.scala:157)
    at play.api.libs.json.Reads$$anon$6.reads(Reads.scala:195)
    at reactivemongo.play.json.JSONSerializationPack$.deserialize(JSONSerializationPack.scala:59)
Reply all
Reply to author
Forward
0 new messages