Repository navigation
Closed
Milestone
Description
The shading does not work for Linux due to native libraries for custom epoll transport not being shaded.
The problem is being described here: netty/netty#4820
The following stack-trace shows the issue:
java.lang.NoClassDefFoundError: io/netty/channel/epoll/NativeStaticallyReferencedJniMethods
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at org.testcontainers.shaded.io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:193)
at org.testcontainers.shaded.io.netty.channel.epoll.Native.<clinit>(Native.java:60)
at org.testcontainers.shaded.io.netty.channel.epoll.IovArray.<clinit>(IovArray.java:57)
at org.testcontainers.shaded.io.netty.channel.epoll.EpollEventLoop.<init>(EpollEventLoop.java:57)
at org.testcontainers.shaded.io.netty.channel.epoll.EpollEventLoopGroup.newChild(EpollEventLoopGroup.java:78)
at org.testcontainers.shaded.io.netty.channel.epoll.EpollEventLoopGroup.newChild(EpollEventLoopGroup.java:30)
at org.testcontainers.shaded.io.netty.util.concurrent.MultithreadEventExecutorGroup.<init>(MultithreadEventExecutorGroup.java:77)
at org.testcontainers.shaded.io.netty.util.concurrent.MultithreadEventExecutorGroup.<init>(MultithreadEventExecutorGroup.java:48)
at org.testcontainers.shaded.io.netty.channel.MultithreadEventLoopGroup.<init>(MultithreadEventLoopGroup.java:57)
at org.testcontainers.shaded.io.netty.channel.epoll.EpollEventLoopGroup.<init>(EpollEventLoopGroup.java:63)
at org.testcontainers.shaded.io.netty.channel.epoll.EpollEventLoopGroup.<init>(EpollEventLoopGroup.java:51)
at org.testcontainers.shaded.com.github.dockerjava.netty.DockerCmdExecFactoryImpl$UnixDomainSocketInitializer.init(DockerCmdExecFactoryImpl.java:221)
at org.testcontainers.shaded.com.github.dockerjava.netty.DockerCmdExecFactoryImpl.init(DockerCmdExecFactoryImpl.java:197)
at org.testcontainers.shaded.com.github.dockerjava.core.DockerClientImpl.withDockerCmdExecFactory(DockerClientImpl.java:159)
at org.testcontainers.shaded.com.github.dockerjava.core.DockerClientBuilder.build(DockerClientBuilder.java:45)
at org.testcontainers.dockerclient.DockerClientProviderStrategy.getClientForConfig(DockerClientProviderStrategy.java:103)
at org.testcontainers.dockerclient.EnvironmentAndSystemPropertyClientProviderStrategy.test(EnvironmentAndSystemPropertyClientProviderStrategy.java:18)
at org.testcontainers.dockerclient.DockerClientProviderStrategy.getFirstValidStrategy(DockerClientProviderStrategy.java:54)
at org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:82)
at org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:70)
at org.testcontainers.containers.GenericContainer.<init>(GenericContainer.java:105)
at org.testcontainers.containers.FixedHostPortGenericContainer.<init>(FixedHostPortGenericContainer.java:16)
Metadata
Metadata
Assignees
Labels
No labels
Activity
dbalakirev commentedon Jul 18, 2016
Same for me. Latest code from today.
rnorth commentedon Jul 18, 2016
Ouch - sorry. I'll check the PR and will aim to release tonight.
Could you perhaps let me know what configuration you're running under, e.g. OS, Docker installation method etc? Clearly I should have caught this before, and need to add a different permutation to pre-release testing (on top of Mac and two different Linux CI services 😟 )!
raphw commentedon Jul 18, 2016
I run a recent version of Ubuntu:
I assume that most infrastructure is on virtual servers. Mac does not have Unix sockets so I guess the outcome is different. I tested a custom build of Testcontainers with my project and the Netty problems and Guava problems I have had went away.
rnorth commentedon Jul 19, 2016
Just released 1.1.2 - will be rolling out to Maven Central soon.
valdisrigdon commentedon Jul 20, 2016
Testing v1.1.2 and I'm seeing this now on an AWS machine:
rnorth commentedon Jul 20, 2016
OK, sorry about this. Yet more digging to do!☹️
Richard
raphw commentedon Jul 20, 2016
It appears as if the system property is not applied in the above code. Maybe, the library is loaded before the property initializer is applied? I wonder if Amazon executes initializers lazily. Can you try setting:
on startup?
rnorth commentedon Jul 20, 2016
That makes sense - I'm curious to see this. I'm trying to think what could
cause this difference in behaviour. @valdisrigdon I can't recall if you
said you were on Oracle/Open JDK...
If it emerges that this is the cause we at least have the option of calling
the necessary setProperty in Testcontainers itself. That would be worst
case, but we're not without options.
@raphw thanks for your continuing involvement in this issue!
On Wed, 20 Jul 2016 at 20:39 Rafael Winterhalter notifications@github.com
wrote:
dbalakirev commentedon Jul 22, 2016
1.1.2 works for me as well. Many thanks!
irmac commentedon Jul 26, 2016
I'm also seeing the same error as @valdisrigdon running on my laptop with testcontainers
1.1.2 and
raphw commentedon Jul 26, 2016
@irmac How do you trigger
DockerComposeContainerwithout loadingGenericContainer, i.e. how does yourMetadataRepositoryITlook like? To me, it seems like there are muliple entry points. The problem is that Testcontainers.org must set this system property before the library is loaded but from the both reports, it seems like there are multiple ways of doing so.I assume you have a field
DockerComposeContainerin your class. Can you change its type toGenericContainerand try if this helps? Alternatively, it might help to trigger the field from a@BeforeClassmethod rather than statically.valdisrigdon commentedon Jul 26, 2016
I'm triggering a call to
org.testcontainers.DockerClientFactory.instance().client(true). If I explicitly set the System property before this, it works as expected.rnorth commentedon Jul 26, 2016
Ah, this makes sense if going via
DockerComposeContainer. This stopped subclassingGenericContainerin the 1.1.0 release, so it seems probable that the route to obtaining aDockerClientinstance is not initialising theGenericContainerclass.I think the
System.setProperty(...)static call should probably be transplanted over toDockerClientFactory, which is the common element in the path to obtaining the client instance.irmac commentedon Jul 26, 2016
Here's the test class...
irmac commentedon Jul 26, 2016
@raphw @rnorth Thanks for the help chaps, I understand the problem now. I've got a local workaround in place following the suggestion of @rnorth.
Unless someone else is working on this (in which case, great!) I'd like to submit a pull request for this issue. Is there consensus on whether the property setting logic should be duplicated or extracted somewhere shared ( perhaps a default method ?)
rnorth commentedon Jul 26, 2016
@irmac thanks, that'd be great. Logically I'd have thought moving the static initialiser to DockerClientFactory should be safe for anything relating to shaded netty. It might be a good idea to test and poke holes in this theory, though, just in case there's another entry point.
If that fails, a static initialiser on an interface that both GenericContainer and DockerComposeContainer implement would probably be the next valid way to do it.
I haven't looked yet, but I'm assuming nobody knows of another mechanism for setting the prefix (e.g. ServiceLoader, anything else?)
raphw commentedon Jul 26, 2016
@rnorth No, there is no way. I already looked into alternatives when doing the initial PR as I found it clumsy myself but this is the way to go. If there is a single entry point to accessing Netty; this is where the call goes.
rnorth commentedon Jul 26, 2016
@irmac I'm working on some other PRs this evening so happy to do this while I'm on a roll - I hope this is OK!
irmac commentedon Jul 26, 2016
@rnorth That's great - I'm afraid I've lost any development time this evening!
Change location of system property setting to ensure that netty reloc…
Change location of system property setting to ensure that netty reloc…