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: zio/ZIO$Fail #2325

Closed
nilius opened this issue Nov 25, 2021 · 6 comments
Closed

NoClassDefFoundError: zio/ZIO$Fail #2325

nilius opened this issue Nov 25, 2021 · 6 comments

Comments

@nilius
Copy link

nilius commented Nov 25, 2021

Version: 3.11.0
Module: quill-jdbc / quill-jdbc-monix / quill-async-postgres
Database: Postgres

Expected behavior

No Exceptions thrown.
ZIO dependencies should be an implementation detail of quill and not require the app to explicitly depend on ZIO libs.

Actual behavior

Sometimes we see the following exception during unit test teardown. Test finishes successfully, though.

Exception in thread "Thread-23" java.lang.NoClassDefFoundError: zio/ZIO$Fail
	at zio.ZIO$.haltWith(ZIO.scala:3457)
	at zio.ZIO$.die(ZIO.scala:2647)
	at zio.internal.FiberContext.evaluateNow(FiberContext.scala:659)
	at zio.Runtime.unsafeRunWith(Runtime.scala:214)
	at zio.Runtime.unsafeRunSync(Runtime.scala:83)
	at zio.Runtime.unsafeRunSync$(Runtime.scala:80)
	at zio.Runtime$$anon$3.unsafeRunSync(Runtime.scala:280)
	at zio.Runtime.unsafeRun(Runtime.scala:58)
	at zio.Runtime.unsafeRun$(Runtime.scala:57)
	at zio.Runtime$$anon$3.unsafeRun(Runtime.scala:280)
	at zio.Runtime$.$anonfun$unsafeFromLayer$4(Runtime.scala:308)
	at zio.internal.PlatformSpecific$$anon$1.run(PlatformSpecific.scala:37)
Caused by: java.lang.ClassNotFoundException: zio.ZIO$Fail
	at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
	... 12 more

A ZIO class seems to be required, but not bundled with quill. We have no ZIO dependencies in our app ourself.

Steps to reproduce the behavior

We would need to provide a scaled-down version of our app. The exception ist not happening every time though.

Workaround

Could probably be fixed by adding an explicit dependency to a ZIO lib.

@getquill/maintainers

@vladimirkl
Copy link
Contributor

vladimirkl commented Nov 26, 2021

Getting same error on sbt exit. And it looks to be related to #1715 implementation as it uses zio-logging now. Explicit zio dependency doesn't help at all. Steps to reproduce on any project using quill:

  1. run sbt
  2. run clean and compile
  3. exit sbt
[info] shutting down sbt server
Exception in thread "Thread-30" Exception in thread "Thread-56" java.lang.NoClassDefFoundError: zio/ZIO$Fail
...

I believe that this is related to ZIO environment unloading after logging queries.

@deusaquilus
Copy link
Collaborator

Will fix this issue for 3.12.0. For now try -Dquill.log.file=false.

@deusaquilus
Copy link
Collaborator

@nilius I've decided to incorporate various ZIO infrastructure into Quill since Quill's motto of zero-dependencies is starting to get unsustainable. That is because zero-dependencies ultimately means that you have to do everything yourself. We have already built our own IO monad, our own tracing system, our own ADT transformation system, and contexts for 3 different driver-frameworks for 6 different databases (6 driver-frameworks for 9 databases if you count all the big-data things), the Quill deploy alone has ~100 jars. This is getting totally unsustainable. Meanwhile, users are complaining about the Quill contexts being buggy and there much context-specific code I can never hope to get to. Right now I am at a breaking point. Either I choose a pre-existing infrastructure library to use for my base-context implementations or I give it all up.

So instead I've decided to start incorporating ZIO components. Firstly in order to ship new features like Query-logging but eventually to be able to rewrite the contexts so that I can continue maintaining this project.

As for the zio.ZIO$Fail issue, I'm going to work on it and try to fix it before the next release.

@tschuchortdev
Copy link
Contributor

@deusaquilus I can definitely understand the stress of having to maintain an open source project in your free time. What does that mean for the future with respect to available contexts? Will only zio-jdbc be supported? I would definitely appreciate it if there was another well maintained non-zio-specific context with streaming available. Firstly because it would be a hard sell at work to use all the ZIO stuff and secondly because I have a feeling that the ZIO-team is stretching itself too thin, so I don't fully trust the non-core ZIO libraries. Perhaps something based on Doobie or jasync with Monix would work; both projects seem fairly active.

@deusaquilus
Copy link
Collaborator

@tschuchortdev Contexts will keep the same external APIs but might be different under the hood. For the most part I am sticking to the ZIO-Core libraries which are well maintained. Once ZIO 2 is out I won't even need a zio-logging dependency since it will be part of the core functionality.

@guizmaii
Copy link
Member

See also #2333

guizmaii added a commit that referenced this issue Oct 19, 2023
guizmaii added a commit that referenced this issue Oct 19, 2023
guizmaii added a commit that referenced this issue Oct 20, 2023
juliano pushed a commit that referenced this issue Oct 20, 2023
guizmaii added a commit that referenced this issue Oct 20, 2023
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

5 participants