Skip to content

classes conflict when using docker-java for production code #2860

Closed
@juwit

Description

@juwit

Hi there !

First, thank you for the great work. I use testcontainers since a few months, and it's great !

I have an issue in one of my app using :

  • docker-java 3.2.2 for production code, with transport-zerodep
  • testcontainers 1.14.3 for integration testing

This kind of code raises a NoSuchMethodError when executed in an integration test :

@Bean
DockerClient client(DockerClientConfig config, DockerHttpClient transport){
    return DockerClientImpl.getInstance(config, transport);
}
Caused by: java.lang.NoSuchMethodError: com.github.dockerjava.core.DockerClientImpl.getInstance(Lcom/github/dockerjava/core/DockerClientConfig;Lcom/github/dockerjava/transport/DockerHttpClient;)Lcom/github/dockerjava/api/DockerClient;

When digging a little, I found out that test containers embeds docker-java 3.2.0, and the classes are not shaded. So It conflicts with my production code using docker-java 3.2.2.
It seems that this getInstance method was added in docker-java 3.2.2 (others are deprecated).

As a workaround, I stick with docker-java 3.2.0, and a transport-okhttp for now, but still, this issue could help someone else :)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions