lloydmeta / enumeratum

A type-safe, reflection-free, powerful enumeration implementation for Scala with exhaustive pattern match warnings and helpful integrations.
MIT License
1.18k stars 146 forks source link

Enumeratum-Play 1.8.0 with Play 3 and Pekko cannot find play.api.libs.json.KeyReads at runtime #388

Closed sentenza closed 6 months ago

sentenza commented 6 months ago

While running a scalatest after upgrading to Pekko and Play 3.0.1 I got the following error.

I'm using Guice 6.0.0 and scalatestplus-play 7.0.1

[info]   Cause: java.lang.ExceptionInInitializerError: Exception java.lang.NoSuchMethodError: 'void play.api.libs.json.KeyReads.$init$(play.api.libs.json.KeyReads)' [in thread "application-pekko.actor.default-dispatcher-7"]
[info]   at enumeratum.EnumFormats$$anon$4.<init>(EnumFormats.scala:148)
[info]   at enumeratum.EnumFormats$.readsKeyAndExtracts(EnumFormats.scala:148)
[info]   at enumeratum.EnumFormats$.keyReads(EnumFormats.scala:35)
[info]   at enumeratum.PlayInsensitiveJsonEnum.$init$(PlayInsensitiveJsonEnum.scala:16)
[info]   at io.kontainers.validation.model.ModelType$.<clinit>(ModelType.scala:8)
[info]   at io.kode.daos.ValidationsDao.<init>(ValidationsDao.scala:26)
[info]   at io.kode.daos.ValidationsDao$$FastClassByGuice$$5403b7b.GUICE$TRAMPOLINE(<generated>)
[info]   at io.kode.daos.ValidationsDao$$FastClassByGuice$$5403b7b.apply(<generated>)
[info]   at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:82)
[info]   at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:114)

A possible workaround to get rid of this error requires to exclude transitive dependencies, adding to build.sbt:

excludeDependencies ++= Seq(
  // As of Play 3.0, groupId has changed to org.playframework; exclude transitive dependencies to the old artifacts
  ExclusionRule(organization = "com.typesafe.play")
)
lloydmeta commented 6 months ago

Interesting.... any idea where the transitive dependency could be coming from?

sentenza commented 6 months ago

Interesting.... any idea where the transitive dependency could be coming from?

op-rabbit https://github.com/pjfanning/op-rabbit/pull/6