M1 image building problems with docker-java 3.2.13 ("NoClassDefFoundError: Could not initialize class com.sun.jna.Native")
See original GitHub issueHey, when using the gradle docker plugin 7.3.0 which uses docker-java 3.2.13 then there is an NoClassDefFoundError error when trying to build docker images (maybe related to Java 11 !?). As you can see, the exception comes from the dockerjava code and the maintainer of docker-plugin @bmuschko asked me to post this issue here (see https://github.com/bmuschko/gradle-docker-plugin/issues/1070):
./gradle :docker:image
with plugin 7.3.0:
> Task :docker:baseImage
Building image using context '/Users/.../docker/build'.
Using Dockerfile '/Users/.../docker/build/Dockerfile'
Using images 'demo:1.1.0-a07f741-SNAPSHOT-base'.
Exception in thread "docker-java-stream--473973909" java.lang.NoClassDefFoundError: Could not initialize class com.sun.jna.Native
at com.github.dockerjava.transport.DomainSocket.<clinit>(DomainSocket.java:54)
at com.github.dockerjava.transport.UnixSocket.get(UnixSocket.java:29)
at com.github.dockerjava.httpclient5.ApacheDockerHttpClientImpl$2.createSocket(ApacheDockerHttpClientImpl.java:153)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.io.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:125)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:409)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.InternalExecRuntime.connectEndpoint(InternalExecRuntime.java:164)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.InternalExecRuntime.connectEndpoint(InternalExecRuntime.java:174)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ConnectExec.execute(ConnectExec.java:135)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ProtocolExec.execute(ProtocolExec.java:172)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.HttpRequestRetryExec.execute(HttpRequestRetryExec.java:93)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ContentCompressionExec.execute(ContentCompressionExec.java:128)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.RedirectExec.execute(RedirectExec.java:116)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute(InternalHttpClient.java:178)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:67)
at com.github.dockerjava.httpclient5.ApacheDockerHttpClientImpl.execute(ApacheDockerHttpClientImpl.java:191)
at com.github.dockerjava.httpclient5.ApacheDockerHttpClient.execute(ApacheDockerHttpClient.java:9)
at com.github.dockerjava.core.DefaultInvocationBuilder.execute(DefaultInvocationBuilder.java:228)
at com.github.dockerjava.core.DefaultInvocationBuilder.lambda$executeAndStream$1(DefaultInvocationBuilder.java:269)
at java.base/java.lang.Thread.run(Thread.java:829)
FYI: ./gradle :docker:image
with plugin 7.2.0 (uses docker-java ) seems to fail at some different error:
> Task :docker:baseImage FAILED
Building image using context '/Users/.../docker/build'.
Using Dockerfile '/Users/.../docker/build/Dockerfile'
Execution failed for task ':docker:baseImage'.
> group id '1912341234' is too big ( > 2097151 ). Use STAR or POSIX extensions to overcome this limit
So maybe something broke from 3.2.12 to 3.2.13?
Your Environment
OpenJDK 11.0.15
Output of gradle -version
:
Kotlin: 1.5.31
Groovy: 3.0.9
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 11.0.15 (Homebrew 11.0.15+0)
OS: Mac OS X 12.3.1 aarch64
gradlew :docker:buildEnvironment (docker plugin 7.3.0 with docker-java 3.2.13):
classpath
\--- com.bmuschko.docker-remote-api:com.bmuschko.docker-remote-api.gradle.plugin:7.3.0
\--- com.bmuschko:gradle-docker-plugin:7.3.0
+--- com.github.docker-java:docker-java-core:3.2.13
| +--- com.github.docker-java:docker-java-api:3.2.13
| | +--- com.fasterxml.jackson.core:jackson-annotations:2.10.3
| | \--- org.slf4j:slf4j-api:1.7.30
| +--- com.github.docker-java:docker-java-transport:3.2.13
| +--- org.slf4j:slf4j-api:1.7.30
| +--- commons-io:commons-io:2.6
| +--- org.apache.commons:commons-compress:1.21
| +--- org.apache.commons:commons-lang3:3.12.0
| +--- com.fasterxml.jackson.core:jackson-databind:2.10.3
| | +--- com.fasterxml.jackson.core:jackson-annotations:2.10.3
| | \--- com.fasterxml.jackson.core:jackson-core:2.10.3
| +--- com.google.guava:guava:19.0
| \--- org.bouncycastle:bcpkix-jdk15on:1.64
| \--- org.bouncycastle:bcprov-jdk15on:1.64
+--- com.github.docker-java:docker-java-api:3.2.13 (*)
+--- com.github.docker-java:docker-java-transport-httpclient5:3.2.13
| +--- com.github.docker-java:docker-java-transport:3.2.13
| +--- org.apache.httpcomponents.client5:httpclient5:5.0.3
| | +--- org.apache.httpcomponents.core5:httpcore5:5.0.2
| | +--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
| | \--- commons-codec:commons-codec:1.13
| \--- net.java.dev.jna:jna:5.8.0
+--- javax.activation:activation:1.1.1
\--- org.ow2.asm:asm:9.1
(*) - dependencies omitted (listed previously)
gradlew :docker:buildEnvironment (docker plugin 7.2.0 with docker-java 3.2.12):
classpath
\--- com.bmuschko.docker-remote-api:com.bmuschko.docker-remote-api.gradle.plugin:7.2.0
\--- com.bmuschko:gradle-docker-plugin:7.2.0
+--- com.github.docker-java:docker-java-core:3.2.12
| +--- com.github.docker-java:docker-java-api:3.2.12
| | +--- com.fasterxml.jackson.core:jackson-annotations:2.10.3
| | \--- org.slf4j:slf4j-api:1.7.30
| +--- com.github.docker-java:docker-java-transport:3.2.12
| +--- org.slf4j:slf4j-api:1.7.30
| +--- commons-io:commons-io:2.6
| +--- org.apache.commons:commons-compress:1.21
| +--- commons-lang:commons-lang:2.6
| +--- com.fasterxml.jackson.core:jackson-databind:2.10.3
| | +--- com.fasterxml.jackson.core:jackson-annotations:2.10.3
| | \--- com.fasterxml.jackson.core:jackson-core:2.10.3
| +--- com.google.guava:guava:19.0
| \--- org.bouncycastle:bcpkix-jdk15on:1.64
| \--- org.bouncycastle:bcprov-jdk15on:1.64
+--- com.github.docker-java:docker-java-api:3.2.12 (*)
+--- com.github.docker-java:docker-java-transport-httpclient5:3.2.12
| +--- com.github.docker-java:docker-java-transport:3.2.12
| +--- org.apache.httpcomponents.client5:httpclient5:5.0.3
| | +--- org.apache.httpcomponents.core5:httpcore5:5.0.2
| | +--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
| | \--- commons-codec:commons-codec:1.13
| \--- net.java.dev.jna:jna:5.8.0
+--- javax.activation:activation:1.1.1
\--- org.ow2.asm:asm:9.1
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Image building works fine on M1 and passes tests.
It does look like there is a problem with the dependency versions in your project (
java.lang.NoClassDefFoundError: Could not initialize class com.sun.jna.Native
is usually an indicator that you have JNA that is older than the one that added M1 support), hence the request to provide a reproducer to exclude that case (that has nothing to do withdocker-java
).I will close this issue, but feel free to reopen if you manage to reproduce it in isolation.
@fqzz Jersey transport will not be receiving long term support anymore: https://github.com/docker-java/docker-java/blob/master/docs/transports.md
Please try any other supported transport (e.g. Apache HttpClient5 or its shaded version Zerodep)