embeddedkafka / embedded-kafka

A library that provides an in-memory Kafka instance to run your tests against.
MIT License
371 stars 45 forks source link

Upgrading from 2.7.0 to 2.8.0 - NoSuchMethodError #260

Closed mveeprojects closed 3 years ago

mveeprojects commented 3 years ago

Since upgrading from 2.7.0 to 2.8.0 and having changed all imports from net.manub... to io.github... we have seen the below when trying to use withRunningKafka. Is there something else we also need to do to migrate from 2.7.0 to 2.8.0?

[error] java.lang.NoSuchMethodError: 'boolean kafka.server.KafkaServer$.$lessinit$greater$default$4()'
[error]         at io.github.embeddedkafka.ops.KafkaOps.startKafka(kafkaOps.scala:52)
[error]         at io.github.embeddedkafka.ops.KafkaOps.startKafka$(kafkaOps.scala:26)
francescopellegrini commented 3 years ago

Hi @mveeprojects, can you tell me which Scala version are you using? Are you importing other libraries related to Kafka?

mveeprojects commented 3 years ago

Hi @francescopellegrini - we're using Scala 2.13.5. We are yes, we have "kafka" and "kafka-streams" from "org.apache.kafka" imported as well.

francescopellegrini commented 3 years ago

Hi @francescopellegrini - we're using Scala 2.13.5. We are yes, we have "kafka" and "kafka-streams" from "org.apache.kafka" imported as well.

I've created a simple project with those 3 dependencies alone but I was not able to reproduce your error, unfortunately..

Are there any other dependencies which could cause conflicts? May I also ask you why are you importing kafka itself?

NeQuissimus commented 3 years ago

I've found the best way to deal with this to be adding addDependencyTreePlugin into the SBT project and looking at the tree to figure out what is pulling in the various transitive dependencies.

mveeprojects commented 3 years ago

Sorry it's been a while, going to close this while we look into this. Thanks for your help.

joost-de-vries commented 2 years ago

For me the solution was to define dependencyOverrides

    dependencyOverrides ++= Seq(
      "org.apache.kafka" %% "kafka-clients" % embeddedKafkaVersion,
      "org.apache.kafka" %% "kafka" % embeddedKafkaVersion
    )