-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shading of Netty breaks on Linux because of native bindings #178
Comments
Same for me. Latest code from today. |
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 😟 )! |
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. |
Just released 1.1.2 - will be rolling out to Maven Central soon. |
Testing v1.1.2 and I'm seeing this now on an AWS machine:
|
OK, sorry about this. Yet more digging to do!
|
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: -Dorg.testcontainers.shaded.io.netty.packagePrefix=org.testcontainers.shaded. on startup? |
That makes sense - I'm curious to see this. I'm trying to think what could If it emerges that this is the cause we at least have the option of calling @raphw thanks for your continuing involvement in this issue!
|
1.1.2 works for me as well. Many thanks! |
I'm also seeing the same error as @valdisrigdon running on my laptop with testcontainers Linux version 4.3.5-300.fc23.x86_64 (mockbuild@bkernel02.phx2.fedoraproject.org) (gcc version 5.3.1 20151207 (Red Hat 5.3.1-2) (GCC) ) #1 SMP Mon Feb 1 03:18:41 UTC 2016
openjdk version "1.8.0_92"
OpenJDK Runtime Environment (build 1.8.0_92-b14)
OpenJDK 64-Bit Server VM (build 25.92-b14, mixed mode) java.lang.UnsatisfiedLinkError\: no netty-transport-native-epoll in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1864)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at org.testcontainers.shaded.io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:168)
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.DockerComposeContainer.<init>(DockerComposeContainer.java:72)
at org.testcontainers.containers.DockerComposeContainer.<init>(DockerComposeContainer.java:62)
at MetadataRepositoryIT.<clinit>(MetadataRepositoryIT.java:12)
at sun.misc.Unsafe.ensureClassInitialized(Native Method)
at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:142)
at java.lang.reflect.Field.acquireFieldAccessor(Field.java:1088)
at java.lang.reflect.Field.getFieldAccessor(Field.java:1069)
at java.lang.reflect.Field.get(Field.java:393)
at org.junit.runners.model.FrameworkField.get(FrameworkField.java:73)
at org.junit.runners.model.TestClass.getAnnotatedFieldValues(TestClass.java:230)
at org.junit.runners.ParentRunner.classRules(ParentRunner.java:255)
at org.junit.runners.ParentRunner.withClassRules(ParentRunner.java:244)
at org.junit.runners.ParentRunner.classBlock(ParentRunner.java:194)
at org.junit.runners.ParentRunner.run(ParentRunner.java:362)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
` |
@irmac How do you trigger I assume you have a field |
I'm triggering a call to |
Ah, this makes sense if going via I think the |
Here's the test class... import org.junit.ClassRule;
import org.junit.Test;
import org.testcontainers.containers.DockerComposeContainer;
import java.io.File;
public class MetadataRepositoryIT {
public static final Integer MONGO_PORT = 27017;
@ClassRule
public static DockerComposeContainer environment =
new DockerComposeContainer(new File("src/test/resources/docker-compose-test.yml"))
.withExposedService("mongodb_1", MONGO_PORT);
private final String mongoURL = environment.getServiceHost("mongodb_1",MONGO_PORT)
+ ":" +
environment.getServicePort("mongodb_1", MONGO_PORT);
@Test
public void testDockerComposeTestContainersIT() throws Exception {
System.out.println(mongoURL);
}
} |
@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 ?) |
@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?) |
@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. |
@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! |
@rnorth That's great - I'm afraid I've lost any development time this evening! |
…ated package name is available for DockerCompose usage scenarios. Fixes #178
…ated package name is available for DockerCompose usage scenarios. Fixes #178
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:
The text was updated successfully, but these errors were encountered: