testcontainers-java: Fails on m1 mac docker preview, java.lang.NoClassDefFoundError: Could not initialize class com.sun.jna.Native
https://www.docker.com/blog/download-and-try-the-tech-preview-of-docker-desktop-for-m1/
(possibly wrong repo to report this to)
UnixSocketClientProviderStrategy: failed with exception RuntimeException (java.lang.NoClassDefFoundError: Could not initialize class com.sun.jna.Native). Root cause NoClassDefFoundError (Could not initialize class com.sun.jna.Native)
1.490 [id=16] WARNING o.t.u.TestcontainersConfiguration#readProperties: Attempted to read Testcontainers configuration file at file:/Users/timja/.testcontainers.properties but the file was not found. Exception message: FileNotFoundException: /Users/timja/.testcontainers.properties (No such file or directory)
1.496 [id=16] INFO o.t.d.DockerMachineClientProviderStrategy#isApplicable: docker-machine executable was not found on PATH ([/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home/bin, /Users/timja/bin, /usr/local/bin, /usr/local/bin, /usr/bin, /bin, /usr/sbin, /sbin, /Users/timja/code/jenkins/backend-commit-history-parser/bin])
1.675 [id=16] SEVERE o.t.d.DockerClientProviderStrategy#lambda$getFirstValidStrategy$7: Could not find a valid Docker environment. Please check configuration. Attempted configurations were:
1.675 [id=16] SEVERE o.t.d.DockerClientProviderStrategy#lambda$getFirstValidStrategy$7: UnixSocketClientProviderStrategy: failed with exception RuntimeException (java.lang.NoClassDefFoundError: Could not initialize class com.sun.jna.Native). Root cause NoClassDefFoundError (Could not initialize class com.sun.jna.Native)
1.675 [id=16] SEVERE o.t.d.DockerClientProviderStrategy#lambda$getFirstValidStrategy$7: As no valid configuration was found, execution cannot continue
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 21 (8 by maintainers)
Commits related to this issue
- Update TestContainers to 1.15.3 This version has fixes in JNA for ARM64 (https://github.com/testcontainers/testcontainers-java/issues/3610) — committed to martin-g/drill by martin-g 3 years ago
- Update TestContainers to 1.15.3 This version has fixes in JNA for ARM64 (https://github.com/testcontainers/testcontainers-java/issues/3610) — committed to martin-g/drill by martin-g 3 years ago
- build(core): Enable M1 support for tests * To run the postgres container on the M1 chip, we need a correct version of JNA 5.8 This version should be set as a dependency of org.testcontainers of versi... — committed to Vojtech-Sassmann/perun by Vojtech-Sassmann 3 years ago
- build(core): Enable M1 support for tests * To run the postgres container on the M1 chip, we need a correct version of JNA 5.8 This version should be set as a dependency of org.testcontainers of versi... — committed to Vojtech-Sassmann/perun by Vojtech-Sassmann 3 years ago
- build(core): Enable M1 support for tests * To run the postgres container on the M1 chip, we need a correct version of JNA 5.8 This version should be set as a dependency of org.testcontainers of versi... — committed to CESNET/perun by Vojtech-Sassmann 3 years ago
3.2.7 depends on JNA 5.5.0 (not compatible with M1), 3.2.8 on 5.8.0 (compatible).
Also, we just released Testcontainers 1.15.3 and it depends on JNA 5.8.0 ๐
@bsideup released version 1.15.3 still depends on
which depends on jna 5.2.0 which causes (for me locally) to only pull 5.2.0 and skip 5.8.0 ๐ฆ
I 've added manual dependency to 5.8.0 and it worked only after that ๐ no worries but it could help to @todor-kolev
I should be checking updates more often indeed )) thnx
@todor-kolev soon, but you donโt have to wait for it to be released, just add JNA 5.8.0 to your dependencies list (as @pie-ai did). Also, docker-java 3.2.8 is already released and depends on 5.8.0, you can update the docker-java dependency as an alternative
The root cause is JNA and its lacking M1 support - consider reporting to them. Also, I was able to run it with Rosetta (since my IDEA is running with Rosetta already)
FYI even tho the โcoreโ functionality of Testcontainers works (Ryuk, alpine checks, connectivity), some modules (like Kafka) are failing. I hope future versions of Docker Desktop preview would fix it.
Thanks docker-java 3.2.8 worked for me on M1 to detect docker from test-containers (Docker Desktop RC 3). Version 3.2.7 did not detect docker.