[Bug]: NoClassDefFoundError (Could not initialize class com.github.dockerjava.transport.DomainSocket)
Module
Core
Testcontainers version
1.17.3
Using the latest Testcontainers version?
Yes
Host OS
MacOS
Host Arch
ARM
Docker version
Client:
Version: 20.10.16
API version: 1.41
Go version: go1.17.10
Git commit: aa7e414
Built: Wed Jun 1 21:26:39 2022
OS/Arch: darwin/arm64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.11
API version: 1.41 (minimum version 1.12)
Go version: go1.16.9
Git commit: 847da18
Built: Thu Nov 18 00:34:44 2021
OS/Arch: linux/arm64
Experimental: false
containerd:
Version: 1.4.12
GitCommit: 7b11cfaabd73bb80907dd23182b9347b4245eb5d
runc:
Version: 1.0.2
GitCommit: v1.0.2-0-g52b36a2
docker-init:
Version: 0.19.0
GitCommit: de40ad0
What happened?
Fails to start with exception with exception NoClassDefFoundError (Could not initialize class com.github.dockerjava.transport.DomainSocket)
Newest version used.
Java 11.0.15-zulu arm.
Relevant log output
2022-07-13 09:45:52,656 [Test worker] DEBUG o.t.j.ContainerDatabaseDriver - Container not found in cache, creating new instance
2022-07-13 09:45:52,689 [Test worker] DEBUG o.t.u.TestcontainersConfiguration - Testcontainers configuration overrides will be loaded from file:/Users/jglapa/.testcontainers.properties
2022-07-13 09:45:52,695 [Test worker] INFO o.t.u.ImageNameSubstitutor - Image name substitution will be performed by: DefaultImageNameSubstitutor (composite of 'ConfigurationFileImageNameSubstitutor' and 'PrefixingImageNameSubstitutor')
2022-07-13 09:45:52,740 [Test worker] INFO o.t.d.DockerClientProviderStrategy - Loaded org.testcontainers.dockerclient.UnixSocketClientProviderStrategy from ~/.testcontainers.properties, will try it first
2022-07-13 09:45:52,741 [Test worker] DEBUG o.t.d.DockerClientProviderStrategy - Trying out strategy: UnixSocketClientProviderStrategy
2022-07-13 09:45:53,242 [Test worker] INFO o.a.c.c.C.[.[.[/] - Initializing Spring embedded WebApplicationContext
2022-07-13 09:45:53,504 [Test worker] INFO o.t.d.DockerClientProviderStrategy - Loaded org.testcontainers.dockerclient.UnixSocketClientProviderStrategy from ~/.testcontainers.properties, will try it first
2022-07-13 09:45:53,505 [Test worker] DEBUG o.t.d.DockerClientProviderStrategy - Trying out strategy: UnixSocketClientProviderStrategy
2022-07-13 09:45:53,506 [Test worker] DEBUG o.t.d.DockerClientProviderStrategy - UnixSocketClientProviderStrategy: failed with exception NoClassDefFoundError (Could not initialize class com.github.dockerjava.transport.DomainSocket)
2022-07-13 09:45:53,508 [Test worker] INFO o.t.d.DockerMachineClientProviderStrategy - docker-machine executable was not found on PATH ([..redacted...])
2022-07-13 09:45:53,508 [Test worker] ERROR o.t.d.DockerClientProviderStrategy - Could not find a valid Docker environment. Please check configuration. Attempted configurations were:
2022-07-13 09:45:53,508 [Test worker] ERROR o.t.d.DockerClientProviderStrategy - UnixSocketClientProviderStrategy: failed with exception NoClassDefFoundError (Could not initialize class com.github.dockerjava.transport.DomainSocket)
2022-07-13 09:45:53,508 [Test worker] ERROR o.t.d.DockerClientProviderStrategy - As no valid configuration was found, execution cannot continue
Additional Information
2960 +--- org.testcontainers:postgresql:1.17.3 2961 | --- org.testcontainers:jdbc:1.17.3 2962 | --- org.testcontainers:database-commons:1.17.3 2963 | --- org.testcontainers:testcontainers:1.17.3 2964 | +--- junit:junit:4.13.2 () 2965 | +--- org.slf4j:slf4j-api:1.7.36 2966 | +--- org.apache.commons:commons-compress:1.21 2967 | +--- org.rnorth.duct-tape:duct-tape:1.0.8 2968 | | --- org.jetbrains:annotations:17.0.0 2969 | +--- com.github.docker-java:docker-java-api:3.2.13 2970 | | +--- com.fasterxml.jackson.core:jackson-annotations:2.10.3 -> 2.13.3 () 2971 | | --- org.slf4j:slf4j-api:1.7.30 -> 1.7.36 2972 | --- com.github.docker-java:docker-java-transport-zerodep:3.2.13 2973 | +--- com.github.docker-java:docker-java-transport:3.2.13 2974 | +--- org.slf4j:slf4j-api:1.7.25 -> 1.7.36 2975 | --- net.java.dev.jna:jna:5.8.0
seems like problem goes away when switching to java11 amd64 e.g. (11.0.2-openjdk)
Are you sure that the actual runtime classpath contains an up-to-date version of JNA?
any suggestion how could I verify that at runtime? Gradle dependency check claims its 5.8.0
Hi everyone, any update here? Thanks!
Encountering this on mac m1 using testcontainers-java:1.17.3. I tried upgrade to jna:5.8.0 and seem to work.
...
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>5.8.0</version>
<scope>test</scope>
</dependency>
...
Updated : Additional details here -> https://github.com/testcontainers/testcontainers-java/issues/3834
@jglapa run ./gradlew dependencies or that's what you mean by Gradle dependency check claims its 5.8.0
Closing due to there is no answer. @jglapa feel free to reopen this issue.
sorry, the notification got lost somehow, we worked around the issue by forcing JNA to later version with:
...
implementation 'net.java.dev.jna:jna'
constraints {
implementation('net.java.dev.jna:jna:5.12.1') {
because '5.8 and 5.11 cause errors on Apple - M1'
}
}
...