testcontainers-java icon indicating copy to clipboard operation
testcontainers-java copied to clipboard

Java 9 module support

Open eksd opened this issue 7 years ago • 15 comments

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?

eksd avatar Dec 14 '17 10:12 eksd

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());

bsideup avatar Dec 14 '17 10:12 bsideup

Yes, now it works. Thx!

eksd avatar Dec 14 '17 13:12 eksd

@eksd I'll keep issue open because we might set it automatically in TestContainers :)

bsideup avatar Dec 14 '17 13:12 bsideup

@bsideup Do we still need to keep this open? After all, we have a working JDK9 build now.

kiview avatar Feb 02 '18 17:02 kiview

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?

reda-alaoui avatar Feb 25 '18 11:02 reda-alaoui

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

reda-alaoui avatar Feb 25 '18 14:02 reda-alaoui

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?

kiview avatar Feb 25 '18 22:02 kiview

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.

reda-alaoui avatar Feb 25 '18 22:02 reda-alaoui

The consuming module will need to have a real  module-info.java

reda-alaoui avatar Feb 27 '18 15:02 reda-alaoui

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.

stale[bot] avatar Oct 28 '18 02:10 stale[bot]

The issue is still relevant.

reda-alaoui avatar Oct 28 '18 08:10 reda-alaoui

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 identifier

And the test fails with:

java.lang.NoClassDefFoundError: org/rnorth/visibleassertions/VisibleAssertions

These 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.

rnorth avatar Nov 29 '18 09:11 rnorth

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.

alexanderkjall avatar Dec 18 '18 19:12 alexanderkjall

Junixsocket is fixed

reda-alaoui avatar Dec 27 '18 09:12 reda-alaoui

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

alexanderkjall avatar Dec 27 '18 18:12 alexanderkjall