Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoClassDefFoundError with Scala 2.x when cats-core isn't imported directly #669

Closed
gaelrenoux opened this issue May 28, 2023 · 0 comments
Closed

Comments

@gaelrenoux
Copy link

I've found this issue when upgrading tranzactio to use version 23.0.0.5 instead of 3.3.0. The tests would break on Scala 2.x with:

java.lang.ExceptionInInitializerError: Exception java.lang.NoClassDefFoundError: cats/FlatMapArityFunctions [in thread "ZScheduler-Worker-1"]
    		at zio.interop.CatsZioInstances2.<init>(cats.scala:207)
    		at zio.interop.CatsZioInstances1.<init>(cats.scala:173)
    		at zio.interop.CatsZioInstances.<init>(cats.scala:148)
    		at zio.interop.CatsEffectInstances.<init>(cats.scala:96)
    		at zio.interop.CatsEffectPlatform.<init>(cats.scala:75)
    		at zio.interop.catz$.<init>(cats.scala:37)
    		at zio.interop.catz$.<clinit>(cats.scala:37)
    		at io.github.gaelrenoux.tranzactio.doobie.package$Database$.$anonfun$connectionFromJdbc$1(package.scala:50)

I fixed it by explicitly importing cats-core in commit bd953aa. You can easily reproduce by simply running sbt clean +test before and after the commit. Note that my use of optional dependencies in tranzactio has nothing to with it, as I was able to reproduce even with those dependencies set as Compile. The tests work on Scala 3.

The issue was also reported by Discord user zjzupzp when using the library.

I tried to investigate a bit, and found something curious: when running dependencyTree, it's not the same between Scala versions.

  • On Scala 3.2.2, zio-interop-cats has a dependency on co.fs2:fs2-core_3:3.6.1, which brings all of Cats with it.
  • On Scala 2.13.10 and 2.12.17, zio-interop-cats has no dependency on Cats whatsoever.

Maybe zio-interop-cats should always have a dependency on cats-core? This isn't a critical issue, as there's the simple workaround of importing cats-core directly, but it's strange nonetheless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant