I'm trying to use the Docker-Java API. Following the instruction in https://github.com/docker-java/docker-java/blob/main/docs/getting_started.md I build a DockerClientConfig and try to build a DockerHttpClient:
DockerClientConfig config = DefaultDockerClientConfig.createDefaultConfigBuilder().build();
DockerHttpClient httpClient = new ApacheDockerHttpClient.Builder()
.dockerHost(config.getDockerHost())
.sslConfig(config.getSSLConfig())
.maxConnections(100)
.connectionTimeout(Duration.ofSeconds(30))
.responseTimeout(Duration.ofSeconds(45))
.build();
Then the error comes out:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hc/client5/http/ssl/TlsSocketStrategy
at com.github.dockerjava.httpclient5.ApacheDockerHttpClient$Builder.build(ApacheDockerHttpClient.java:50)
at com.alibaba.ais.route.monitor.rmc.service.ContainerInfoService.func(ContainerInfoService.java:24) // this refers to "build" for the DockerhttpClient
at com.alibaba.ais.route.monitor.rmc.Application.main(Application.java:15)
Caused by: java.lang.ClassNotFoundException: org.apache.hc.client5.http.ssl.TlsSocketStrategy
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
I included the dependencies in my pom.xml:
<dependency>
<groupId>com.github.docker-java</groupId>
<artifactId>docker-java-core</artifactId>
<version>3.5.0</version>
</dependency>
<dependency>
<groupId>com.github.docker-java</groupId>
<artifactId>docker-java-transport-httpclient5</artifactId>
<version>3.5.0</version>
</dependency>
How do I solve this problem?