Closed
Description
Version used:
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.15.0-rc2</version>
</dependency>
When I attempt to run the test, I get the following exception:
2020-11-04T11:21:36,470 INFO [main] dockerclient.DockerClientProviderStrategy: Loaded org.testcontainers.dockerclient.UnixSocketClientProviderStrategy from ~/.testcontainers.properties, will try it first
2020-11-04T11:21:36,724 INFO [main] dockerclient.DockerMachineClientProviderStrategy: docker-machine executable was not found on PATH ([/opt/jdks/jdk1.8.0_261/bin, /home/stamatis/Programs/apache-maven-3.6.3/bin, /home/stamatis/Projects/Misc/Hive-scripts/, /home/stamatis/.local/bin, /usr/local/sbin, /usr/local/bin, /usr/sbin, /usr/bin, /sbin, /bin, /usr/games, /usr/local/games, /snap/bin])
2020-11-04T11:21:36,754 ERROR [main] dockerclient.DockerClientProviderStrategy: Could not find a valid Docker environment. Please check configuration. Attempted configurations were:
2020-11-04T11:21:36,754 ERROR [main] dockerclient.DockerClientProviderStrategy: UnixSocketClientProviderStrategy: failed with exception NoClassDefFoundError (com/fasterxml/jackson/annotation/JsonMerge). Root cause ClassNotFoundException (com.fasterxml.jackson.annotation.JsonMerge)
2020-11-04T11:21:36,754 ERROR [main] dockerclient.DockerClientProviderStrategy: UnixSocketClientProviderStrategy: failed with exception NoClassDefFoundError (Could not initialize class org.testcontainers.shaded.com.github.dockerjava.core.DefaultObjectMapperHolder)
2020-11-04T11:21:36,754 ERROR [main] dockerclient.DockerClientProviderStrategy: As no valid configuration was found, execution cannot continue
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.516 sec <<< FAILURE!
testQueries(path.to.my.Class) Time elapsed: 0.308 sec <<< ERROR!
org.testcontainers.containers.ContainerLaunchException: Container startup failed
at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:331)
at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:312)
at org.testcontainers.containers.GenericContainer.starting(GenericContainer.java:1025)
at org.testcontainers.containers.FailureDetectingExternalResource$1.evaluate(FailureDetectingExternalResource.java:29)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: org.testcontainers.containers.ContainerFetchException: Can't get Docker image: RemoteDockerImage(imageName=com.company/mini:1.10.0, imagePullPolicy=DefaultPullPolicy())
at org.testcontainers.containers.GenericContainer.getDockerImageName(GenericContainer.java:1282)
at org.testcontainers.containers.GenericContainer.logger(GenericContainer.java:616)
at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:321)
... 25 more
Caused by: java.lang.IllegalStateException: Could not find a valid Docker environment. Please see logs and check configuration
at org.testcontainers.dockerclient.DockerClientProviderStrategy.lambda$getFirstValidStrategy$7(DockerClientProviderStrategy.java:214)
at java.util.Optional.orElseThrow(Optional.java:290)
at org.testcontainers.dockerclient.DockerClientProviderStrategy.getFirstValidStrategy(DockerClientProviderStrategy.java:206)
at org.testcontainers.DockerClientFactory.getOrInitializeStrategy(DockerClientFactory.java:132)
at org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:174)
at org.testcontainers.LazyDockerClient.getDockerClient(LazyDockerClient.java:14)
at org.testcontainers.LazyDockerClient.listImagesCmd(LazyDockerClient.java:12)
at org.testcontainers.images.LocalImagesCache.maybeInitCache(LocalImagesCache.java:68)
at org.testcontainers.images.LocalImagesCache.get(LocalImagesCache.java:32)
at org.testcontainers.images.AbstractImagePullPolicy.shouldPull(AbstractImagePullPolicy.java:18)
at org.testcontainers.images.RemoteDockerImage.resolve(RemoteDockerImage.java:65)
at org.testcontainers.images.RemoteDockerImage.resolve(RemoteDockerImage.java:26)
at org.testcontainers.utility.LazyFuture.getResolvedValue(LazyFuture.java:17)
at org.testcontainers.utility.LazyFuture.get(LazyFuture.java:39)
at org.testcontainers.containers.GenericContainer.getDockerImageName(GenericContainer.java:1280)
... 27 more
Obviously there is a dependency conflict of jackson-annotation that is used by other libraries used in the project. What worked for me was to declare explicitly jackson-annotations on my pom.xml and use a recent version.
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.10.5</version>
</dependency>
I just submitted the issue just in case it is useful to somebody else.