-1

We are trying to upgarde kafka-client from 2.8.2 to 3.4.0 with JAVA 11. But while building the application its failing.

Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.543 sec <<< FAILURE!
testConfigurationNotificationForCMD(com.amadeus.hotel.cde.test.rs.ConfigurationNotificationResourceIntegrationTest)  Time elapsed: 0 sec  <<< ERROR!
java.lang.NoClassDefFoundError: kafka/common/KafkaException
    at org.springframework.kafka.test.context.EmbeddedKafkaContextCustomizer.customizeContext(EmbeddedKafkaContextCustomizer.java:71)
    at org.springframework.boot.test.context.SpringBootContextLoader$ContextCustomizerAdapter.initialize(SpringBootContextLoader.java:330)
    at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:604)
    at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:373)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:306)
    at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:136)
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:141)
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:90)
    at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:124)
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:118)
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
    at org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener.prepareTestInstance(SpringBootDependencyInjectionTestExecutionListener.java:43)
    at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:248)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)

Can someone help me what are the things required to upgarde kafka-client to 3.4.0

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245

1 Answers1

2

Something is odd here. The test is apparently trying to load a class called kafka.common.KafkaException. But according to the javadocs, the real class name is org.apache.kafka.common.KafkaException.

So then I look at the source code for the class where this is occurring.

https://github.com/spring-projects/spring-kafka/blob/main/spring-kafka-test/src/main/java/org/springframework/kafka/test/EmbeddedKafkaBroker.java

... specifically the commit with the title: "kafka-clients 3.3.2 Compatibility". It looks like the test code prior to this commit was using kafka.common.KafkaException !!!

So ... I reckon that you need to update SpringKafka to v3.0.2 or later.

See also the release note for the SpringKafka v3.0.2 release, and this pull request. And this commit too.


Minimum supported JAVA version with kafka-client 3.4.0

The Java version is not the problem. This is a regression in SpringKafka apparently caused by changes in the Kafka client. You just need to use a version of SpringKafka with the fix for the regression.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216