我使用以下Java测试程序作为在Jersey 1.x项目中调用docker-client的概念证明。
public static void main(String[] args) throws Exception {
final DockerClient docker =
new DefaultDockerClient("http://127.0.0.1:4243/");
final String id = "wg";
final String[] command = {"bash", "-c", "ps", "-ef"};
final String execId = docker.execCreate(id, command,
DockerClient.ExecParameter.STDOUT,
DockerClient.ExecParameter.STDERR);
System.out.println("Time before execution = " + new Date());
final LogStream output = docker.execStart(execId);
final String execOutput = output.readFully();
System.out.println("Output of docker exec = " + execOutput);
System.out.println("Time after execution = " + new Date());
System.exit(0);
}
在运行时,我收到以下错误...
线程中的异常" main" 。java.lang.NoSuchMethodError:org.glassfish.jersey.model.internal.CommonConfig(LCOM / Spotify的/搬运工/客户端/阴影/的javax / WS / RS / RuntimeType; Ljersey /重新打包/ COM /谷歌/普通/碱/谓词;)V 在org.glassfish.jersey.client.ClientConfig $ State。(ClientConfig.java:146) 在org.glassfish.jersey.client.ClientConfig。(ClientConfig.java:456) 在org.glassfish.jersey.client.ClientConfig。(ClientConfig.java:465) 在com.spotify.docker.client.DefaultDockerClient。(DefaultDockerClient.java:127) 在DockerClientTest.main(DockerClientTest.java:13)
我以为我可能错过了某个依赖的罐子。但是我通过Maven命令" mvn依赖:copy-dependencies"下载了docker-client-2.7.7-shared.jar的所有依赖jar。这是我在运行时使用的罐子列表...
[cwesley@localhost docker-client]$ ls lib
aopalliance-repackaged-2.3.0-b10.jar jackson-datatype-guava-2.2.3.jar
asm-4.0.jar jackson-jaxrs-base-2.2.3.jar
asm-analysis-4.0.jar jackson-jaxrs-json-provider-2.2.3.jar
asm-commons-4.0.jar jackson-module-jaxb-annotations-2.2.3.jar
asm-tree-4.0.jar javassist-3.18.1-GA.jar
asm-util-4.0.jar javax.annotation-api-1.2.jar
bcpkix-jdk15on-1.51.jar javax.inject-2.3.0-b10.jar
bcprov-jdk15on-1.51.jar javax.ws.rs-api-2.0.1.jar
commons-codec-1.6.jar jersey-apache-connector-2.13.jar
commons-compress-1.8.1.jar jersey-client-2.13.jar
commons-lang-2.4.jar jersey-common-2.13.jar
commons-logging-1.1.3.jar jersey-guava-2.13.jar
docker-client-2.7.7-shaded.jar jersey-media-json-jackson-2.13.jar
guava-17.0.jar jffi-1.2.7-native.jar
hk2-api-2.3.0-b10.jar jffi-1.2.7.jar
hk2-locator-2.3.0-b10.jar jnr-constants-0.8.6.jar
hk2-utils-2.3.0-b10.jar jnr-enxio-0.5.jar
httpclient-4.3.5.jar jnr-ffi-2.0.0.jar
httpcore-4.3.2.jar jnr-posix-3.0.8.jar
jackson-annotations-2.2.3.jar jnr-unixsocket-0.4.jar
jackson-core-2.2.3.jar jnr-x86asm-1.0.2.jar
jackson-databind-2.2.3.jar osgi-resource-locator-1.0.1.jar
jackson-dataformat-yaml-2.2.3.jar slf4j-api-1.7.6.jar
我知道CommonConfig类存在于jersey-common-2.13.jar中。我在这里缺少什么?