testcontainers-java
testcontainers-java copied to clipboard
Java 9 module support
There is already exist an #480 issue about problems with running postgreSQL container on java 9 . Are there any plans about upgrading dependencies for better jdk 9 support?
Hi @eksd! It seems that TC works fine on Java 9: https://github.com/Barlog-M/spring-boot-2-example-app
The only change I noted was:
System.setProperty("io.netty.noUnsafe", true.toString());
Yes, now it works. Thx!
@eksd I'll keep issue open because we might set it automatically in TestContainers :)
@bsideup Do we still need to keep this open? After all, we have a working JDK9 build now.
I still have issues with version 1.6.0 and Java 9.
I am using gradle to perform the build.
I am actively using java module by defining a module-info.java file.
You can clone the project from https://github.com/Cosium/vet/tree/27d775e9ae05b0af226f9f4c799c82f3ddcef916.
It errors with:
error: module testcontainers reads package org.newsclub.net.unix from both junixsocket.common and junixsocket.native.common
It seems that https://github.com/kohlschutter/junixsocket is the offender here. Did I miss something?
I fixed my issue by releasing a junixsocket fork on Maven Central.
I opened PR https://github.com/kohlschutter/junixsocket/pull/46 in junixsocket project, but I doubt it will be merged one day, the project has been inactive for 3 years.
Here is the commit https://github.com/Cosium/vet/commit/8cbb21f8f8ab0ea7a950a9bec0c5169f63676795
We are using junixsocket as a dependency in tcp-unix-socket-proxy by @rnorth. Maybe we can find a solution there. Still I wonder why this problem happens, since we are doing a JDK9 build in our CI, or will this only happen to Testcontainers users using JDK9?
Yes. Maybe you should add a jdk 9 consuming module to your CI?
FYI, junixsocket is not the only issue. There is also an issue with some dependency declared as Java Service. I don’t remember which one. I removed testcontainer from the mentionned project for now.
The consuming module will need to have a real module-info.java
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open. If there isn't one already, a PR to fix or at least reproduce the problem in a test case will always help us get back on track to tackle this.
The issue is still relevant.
Helpful summary by @alexanderkjall on #991:
When trying to use testcontainers on the module path you get these warnings:
[WARNING] Can't extract module name from visible-assertions-2.1.1.jar: TtyCheck.class found in top-level directory (unnamed package not allowed in module) [WARNING] Can't extract module name from native-lib-loader-2.0.2.jar: native.lib.loader: Invalid module name: 'native' is not a Java identifier [WARNING] Can't extract module name from junixsocket-native-common-2.0.4.jar: junixsocket.native.common: Invalid module name: 'native' is not a Java identifierAnd the test fails with:
java.lang.NoClassDefFoundError: org/rnorth/visibleassertions/VisibleAssertionsThese are the bugs in the underlying dependencies:
The issue can be reproduced by running the tests in this repository pgjdbc/pgadba with the configuration
<forkCount>0</forkCount>commented out.
The problem with native-lib-loader have been fixed in later releases, testcontainers use version 2.0.2 and the latest released one is 2.3.2 and that one have a fix for this according to the developer.
Junixsocket is fixed
Pull request to fix the dependencies in tcp-unix-socket-proxy that testcontainers depend on: https://github.com/rnorth/tcp-unix-socket-proxy/pull/1