testcontainers / testcontainers-java

Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
https://testcontainers.org
MIT License
7.89k stars 1.62k forks source link

[Bug]: Error after updating to kafka 1.19.8 from 1.19.1 #8757

Closed harry9656 closed 1 month ago

harry9656 commented 1 month ago

Module

Kafka

Testcontainers version

1.19.8

Using the latest Testcontainers version?

Yes

Host OS

MacOS

Host Arch

ARM

Docker version

26.0.0

What happened?

I tried to upgrade the kafka testcontainer from 1.19.1 to 1.19.8 in a Spring boot 3 application written in Java 17. The test compiles and runs fine with version 1.19.1. But after the upgrade, it throws NoClassDefFoundError.

@Testcontainers
@SpringBootTest(classes = KafkaApplication.class)
class KafkaIntegrationTest {

    @Container
    private static final KafkaContainer KAFKA = new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:latest"));
    // Failing in the line above.
}

Relevant log output

java.lang.NoClassDefFoundError: org/testcontainers/containers/ContainerDef
        at com.spring.kafka.delay.KafkaIntegrationTest.<clinit>(KafkaIntegrationTest.java:36)

Additional Information

No response

eddumelendez commented 1 month ago

Please, make sure all your testcontainers dependencies have the same version. I highly recommend using the bom.