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

scala/math/Ordering not found after 2.5.0 update #202

Closed
edrevo opened this issue Aug 28, 2020 · 4 comments
Closed

scala/math/Ordering not found after 2.5.0 update #202

edrevo opened this issue Aug 28, 2020 · 4 comments

Comments

@edrevo
Copy link

edrevo commented Aug 28, 2020

I am using embedded-kafka 2.4.1.1 and it works like a charm. I have tried to update the dependency to 2.5.0, 2.5.1 or 2.6.0 but I get this stacktrace with the newer versions:

[info]   Cause: java.lang.ClassNotFoundException: scala.math.Ordering$$anon$7
[info]   at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
[info]   at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
[info]   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
[info]   at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
[info]   at kafka.api.ApiVersion$.orderingByVersion(ApiVersion.scala:45)
[info]   at kafka.api.ApiVersion.compare(ApiVersion.scala:141)
[info]   at kafka.api.ApiVersion.compare$(ApiVersion.scala:140)
[info]   at kafka.api.KAFKA_2_6_IV0$.compare(ApiVersion.scala:348)
[info]   at kafka.api.KAFKA_2_6_IV0$.compare(ApiVersion.scala:348)
[info]   at scala.math.Ordered.$greater$eq(Ordered.scala:91)

I am using Scala 2.12.12

@francescopellegrini
Copy link
Collaborator

Hi @edrevo,
did you try applying this change? I see that Dependencies.scala still refers to 2.12.11 version, unfortunately...

@mrange
Copy link

mrange commented Sep 26, 2020

I recently ran into this myself when we went from scala 2.12.10 to scala 2.12.12.

From a bit of digging and chatting to the scala maintainers (scala/bug#12162) my belief this is because kafka core inlines scala library hidden class names for performance reasons: https://github.com/apache/kafka/blob/trunk/build.gradle#L520

In kafka they know this leads to ABI compatibility issues but they say:

Inline more aggressively when compiling the core jar since it's not meant to be used as a library.

It seems though EmbeddedKafka is using core as a library (ApiVersion.scala is part of kafka core structure) for its function and thus the inlining of scala library hidden names causes headaches.

One way is locking the scala library dependency to 2.12.10 for our test suites but it's possible other dependencies will fail if they don't get 2.12.12 as they expect.

I have no good idea on how to go on about fixing this as it seems kafka core intentionally is compiled to make minor versions upgrades possibly not work (for performance reasons) as it's not intended to be used a library.

Shadowjar:ing the kafka dependency could maybe work but as it's the core scala library that needs to be shaded it makes it tricky.

Anyway, just wanted to add a bit more context to this issue.

PS. About scala inlining: https://www.lightbend.com/blog/scala-inliner-optimizer

@ennru
Copy link

ennru commented Oct 12, 2020

As Kafka core inlines the Scala library, you can not use a different Scala patch version than what Kafka used to compile its jars. Embedded Kafka for Kafka 2.6.0 requires users to be on Scala 2.12.11 or 2.13.2.

akka/alpakka-kafka#1212 (comment)

@francescopellegrini
Copy link
Collaborator

francescopellegrini commented Dec 21, 2020

Kafka 2.7.0 bumps Scala dependencies to 2.12.12 and 2.13.3 respectively.

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

4 participants