mguenther/kafka-junit

java.lang.NoSuchFieldError: DEFAULT_SOCKET_CONNECTION_SETUP_TIMEOUT_MS

Closed this issue · 2 comments

twoi commented

I tried to run this example from README.md:

class KafkaTest {
    private EmbeddedKafkaCluster kafka;

    @BeforeEach
    void setupKafka() {
        kafka = provisionWith(defaultClusterConfig());
        kafka.start();
    }

    @AfterEach
    void tearDownKafka() {
        kafka.stop();
    }

    @Test
    void shouldWaitForRecordsToBePublished() throws Exception {
        kafka.send(to("test-topic", "a", "b", "c"));
        kafka.observe(on("test-topic", 4));
    }
}

But I'm getting this exception:

java.lang.NoSuchFieldError: DEFAULT_SOCKET_CONNECTION_SETUP_TIMEOUT_MS

	at kafka.server.Defaults$.<clinit>(KafkaConfig.scala:92)
	at kafka.server.KafkaConfig$.<clinit>(KafkaConfig.scala:994)
	at net.mguenther.kafka.junit.EmbeddedKafkaConfig$EmbeddedKafkaConfigBuilder.<init>(EmbeddedKafkaConfig.java:26)
	at net.mguenther.kafka.junit.EmbeddedKafkaConfig$EmbeddedKafkaConfigBuilder.<init>(EmbeddedKafkaConfig.java:20)
	at net.mguenther.kafka.junit.EmbeddedKafkaConfig.brokers(EmbeddedKafkaConfig.java:92)
	at net.mguenther.kafka.junit.EmbeddedKafkaConfig.defaultBrokers(EmbeddedKafkaConfig.java:108)
	at net.mguenther.kafka.junit.EmbeddedKafkaClusterConfig$EmbeddedKafkaClusterConfigBuilder.<init>(EmbeddedKafkaClusterConfig.java:16)
	at net.mguenther.kafka.junit.EmbeddedKafkaClusterConfig.newClusterConfig(EmbeddedKafkaClusterConfig.java:177)
	at net.mguenther.kafka.junit.EmbeddedKafkaClusterConfig.defaultClusterConfig(EmbeddedKafkaClusterConfig.java:194)
	at test.KafkaTest.setupKafka(KafkaTest.java:16)

I've tried this with several versions of kafka-junit: 2.8.0, 2.7.0 and 2.6.0, with the same result.

The project depends on kafka-clients and kafka-streams in version 6.0.1-ccs (i.e. Kafka 2.6).

What do I need to do to fix this?

This is most likely an issue with dependency versioning. Have you checked that there are no duplicate dependencies with different versions on your classpath? If you can provide a short, non-working project example, I'd be able to take brief look at it.

Closed due to inactivity from the reporter.