kohlschutter / junixsocket

Unix Domain Sockets in Java 7 and newer (AF_UNIX), AF_TIPC, AF_VSOCK, and more
Apache License 2.0
438 stars 114 forks source link

UnsatisfiedLinkError: Artifact junixsocket-native-custom does not contain library for amd64-Linux #82

Closed kuldeep992 closed 3 years ago

kuldeep992 commented 4 years ago

java.lang.UnsatisfiedLinkError: Artifact junixsocket-native-custom does not contain library for amd64-Linux at org.newsclub.net.unix.NativeLibraryLoader.findLibraryArtifact(NativeLibraryLoader.java:70) at org.newsclub.net.unix.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:127) at org.newsclub.net.unix.NativeUnixSocket.<clinit>(NativeUnixSocket.java:37) at org.newsclub.net.unix.AFUNIXServerSocket.<init>(AFUNIXServerSocket.java:56) at org.newsclub.net.unix.AFUNIXServerSocket.newInstance(AFUNIXServerSocket.java:69)

I faced an issue with junixsocket lib 2.3.2, related to symbol lookup error: undefined symbol: stat. I commented the details on this ticket: https://github.com/kohlschutter/junixsocket/issues/81

As a workaround, I replaced 2.3.2 with older version i.e. 2.1.0. I choose this specific version because in 2.2.0 the above issue got introduced.

It there something we can do to have a workaround to keep things moving on our end?

Environment details: Host: Docker container of base CentOS-6 image. (docker pull centos:6) Architecture: x86_64

maccuaa commented 4 years ago

Ran into the same issue when this library was invoked via the gradle-docker-plugin (through docker-java).

docker-java: 3.25 gradle-docker-plugin: 5.0.0 OS: RHEL 8.1

$ uname -a
Linux rhel-8 4.18.0-147.5.1.el8_1.x86_64 #1 SMP Tue Jan 14 15:50:19 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Note that the same code has no issue running on Mac OS Mojave or CentOS 7.

21:04:56.200 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger] > Task :esgImage
21:05:02.927 [QUIET] [org.gradle.api.Task] Using tags 'idaas/esg:5.11-SNAPSHOT', 'idaas/esg:latest' for image.
21:05:03.172 [LIFECYCLE] [com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.inject.hk2.AbstractHk2InjectionManager] 
21:05:03.172 [DEBUG] [com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.inject.hk2.AbstractHk2InjectionManager] Clearing Jersey HK2 caches. Service cache size: 3, reflection cache size: 20.
21:05:03.210 [DEBUG] [com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.internal.util.collection.DataStructures] USING LTQ class:class java.util.concurrent.LinkedTransferQueue
21:05:03.251 [DEBUG] [com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.ClientExecutorProvidersConfigurator] null
java.lang.reflect.InvocationTargetException
        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:498)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.ClientExecutorProvidersConfigurator.lookupManagedExecutorService(ClientExecutorProvidersConfigurator.java:176)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.ClientExecutorProvidersConfigurator.<clinit>(ClientExecutorProvidersConfigurator.java:73)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.ClientConfig$State.initRuntime(ClientConfig.java:461)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.internal.util.collection.Values$LazyValueImpl.get(Values.java:341)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.ClientConfig.getRuntime(ClientConfig.java:826)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.ClientRequest.getConfiguration(ClientRequest.java:285)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.JerseyInvocation.validateHttpMethodAndEntity(JerseyInvocation.java:143)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:112)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:108)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:99)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:456)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:357)
        at com.github.dockerjava.jaxrs.async.POSTCallbackNotifier.response(POSTCallbackNotifier.java:29)
        at com.github.dockerjava.jaxrs.async.AbstractCallbackNotifier.call(AbstractCallbackNotifier.java:50)
        at com.github.dockerjava.jaxrs.async.AbstractCallbackNotifier.call(AbstractCallbackNotifier.java:24)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
        at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
        at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:350)
        at javax.naming.InitialContext.lookup(InitialContext.java:417)
        ... 23 more
21:05:03.256 [DEBUG] [com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.ClientExecutorProvidersConfigurator] null
java.lang.reflect.InvocationTargetException
        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:498)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.ClientExecutorProvidersConfigurator.lookupManagedScheduledExecutorService(ClientExecutorProvidersConfigurator.java:198)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.ClientExecutorProvidersConfigurator.init(ClientExecutorProvidersConfigurator.java:148)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.ClientConfig$State.initRuntime(ClientConfig.java:466)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.internal.util.collection.Values$LazyValueImpl.get(Values.java:341)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.ClientConfig.getRuntime(ClientConfig.java:826)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.ClientRequest.getConfiguration(ClientRequest.java:285)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.JerseyInvocation.validateHttpMethodAndEntity(JerseyInvocation.java:143)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:112)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:108)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:99)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:456)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:357)
        at com.github.dockerjava.jaxrs.async.POSTCallbackNotifier.response(POSTCallbackNotifier.java:29)
        at com.github.dockerjava.jaxrs.async.AbstractCallbackNotifier.call(AbstractCallbackNotifier.java:50)
        at com.github.dockerjava.jaxrs.async.AbstractCallbackNotifier.call(AbstractCallbackNotifier.java:24)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
        at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
        at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:350)
        at javax.naming.InitialContext.lookup(InitialContext.java:417)
        ... 23 more
21:05:03.264 [INFO] [com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.process.internal.ExecutorProviders] Selected ExecutorServiceProvider implementation [com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.DefaultClientAsyncExecutorProvider] to be used for injection of executor qualified by [com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.ClientAsyncExecutor] annotation.
21:05:03.265 [INFO] [com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.process.internal.ExecutorProviders] Selected ScheduledExecutorServiceProvider implementation [com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.DefaultClientBackgroundSchedulerProvider] to be used for injection of scheduler qualified by [com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.ClientBackgroundScheduler] annotation.
21:05:03.400 [DEBUG] [com.bmuschko.gradle.docker.shaded.org.apache.http.client.protocol.RequestAddCookies] CookieSpec selected: default
21:05:03.407 [DEBUG] [com.bmuschko.gradle.docker.shaded.org.apache.http.client.protocol.RequestAuthCache] Auth cache not set in the context
21:05:03.408 [DEBUG] [com.github.dockerjava.jaxrs.JerseyDockerCmdExecFactory$1] Connection request: [route: {}->unix://localhost:80][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
21:05:03.420 [DEBUG] [com.github.dockerjava.jaxrs.JerseyDockerCmdExecFactory$1] Connection leased: [id: 0][route: {}->unix://localhost:80][total kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20]
21:05:03.422 [DEBUG] [com.bmuschko.gradle.docker.shaded.org.apache.http.impl.execchain.MainClientExec] Opening connection {}->unix://localhost:80
21:05:03.432 [DEBUG] [com.bmuschko.gradle.docker.shaded.org.apache.http.impl.conn.DefaultManagedHttpClientConnection] http-outgoing-0: Shutdown connection
21:05:03.432 [DEBUG] [com.bmuschko.gradle.docker.shaded.org.apache.http.impl.execchain.MainClientExec] Connection discarded
21:05:03.432 [DEBUG] [com.github.dockerjava.jaxrs.JerseyDockerCmdExecFactory$1] Connection released: [id: 0][route: {}->unix://localhost:80][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
21:05:03.433 [INFO] [com.bmuschko.gradle.docker.shaded.org.apache.http.impl.execchain.RetryExec] I/O exception (java.io.IOException) caught when processing request to {}->unix://localhost:80: Couldn't load native library
21:05:03.433 [DEBUG] [com.bmuschko.gradle.docker.shaded.org.apache.http.impl.execchain.RetryExec] Couldn't load native library
java.io.IOException: Couldn't load native library
        at org.newsclub.net.unix.AFUNIXSocket.setIsCreated(AFUNIXSocket.java:56)
        at org.newsclub.net.unix.AFUNIXSocket.<init>(AFUNIXSocket.java:48)
        at org.newsclub.net.unix.AFUNIXSocket.newInstance(AFUNIXSocket.java:77)
        at org.newsclub.net.unix.AFUNIXSocket.newInstance(AFUNIXSocket.java:72)
        at com.github.dockerjava.jaxrs.ApacheUnixSocket.<init>(ApacheUnixSocket.java:51)
        at com.github.dockerjava.jaxrs.UnixConnectionSocketFactory.createSocket(UnixConnectionSocketFactory.java:66)
        at com.bmuschko.gradle.docker.shaded.org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:119)
        at com.bmuschko.gradle.docker.shaded.org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:373)
        at com.bmuschko.gradle.docker.shaded.org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:394)
        at com.bmuschko.gradle.docker.shaded.org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
        at com.bmuschko.gradle.docker.shaded.org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
        at com.bmuschko.gradle.docker.shaded.org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
        at com.bmuschko.gradle.docker.shaded.org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
        at com.bmuschko.gradle.docker.shaded.org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
        at com.bmuschko.gradle.docker.shaded.org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.apache.connector.ApacheConnector.apply(ApacheConnector.java:450)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:278)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.JerseyInvocation.lambda$invoke$1(JerseyInvocation.java:767)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.internal.Errors.process(Errors.java:316)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.internal.Errors.process(Errors.java:298)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.internal.Errors.process(Errors.java:229)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:414)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:765)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:456)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:357)
        at com.github.dockerjava.jaxrs.async.POSTCallbackNotifier.response(POSTCallbackNotifier.java:29)
        at com.github.dockerjava.jaxrs.async.AbstractCallbackNotifier.call(AbstractCallbackNotifier.java:50)
        at com.github.dockerjava.jaxrs.async.AbstractCallbackNotifier.call(AbstractCallbackNotifier.java:24)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.UnsatisfiedLinkError: Could not load native library junixsocket-native for architecture amd64-Linux
        at org.newsclub.net.unix.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:259)
        at org.newsclub.net.unix.NativeUnixSocket.<clinit>(NativeUnixSocket.java:39)
        at org.newsclub.net.unix.AFUNIXSocket.setIsCreated(AFUNIXSocket.java:54)
        ... 31 more
        Suppressed: java.lang.ClassNotFoundException: org.newsclub.lib.junixsocket.custom.NarMetadata
                at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
                at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
                at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
                at java.lang.Class.forName0(Native Method)
                at java.lang.Class.forName(Class.java:264)
                at org.newsclub.net.unix.NativeLibraryLoader.tryProviderClass(NativeLibraryLoader.java:53)
                at org.newsclub.net.unix.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:219)
                ... 33 more
        Suppressed: java.lang.UnsatisfiedLinkError: no junixsocket-native-2.2.0 in java.library.path
                at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)
                at java.lang.Runtime.loadLibrary0(Runtime.java:871)
                at java.lang.System.loadLibrary(System.java:1124)
                at org.newsclub.net.unix.NativeLibraryLoader$StandardLibraryCandidate.load(NativeLibraryLoader.java:108)
                at org.newsclub.net.unix.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:235)
                ... 33 more
        Suppressed: java.lang.UnsatisfiedLinkError: /tmp/libtmp8482477815352950145libjunixsocket-native-2.2.0.so: /tmp/libtmp8482477815352950145libjunixsocket-native-2.2.0.so: failed to map segment from shared object
                at java.lang.ClassLoader$NativeLibrary.load(Native Method)
                at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1934)
                at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1817)
                at java.lang.Runtime.load0(Runtime.java:810)
                at java.lang.System.load(System.java:1088)
                at org.newsclub.net.unix.NativeLibraryLoader$ClasspathLibraryCandidate.load(NativeLibraryLoader.java:158)
                at org.newsclub.net.unix.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:235)
                ... 33 more
        Suppressed: java.lang.UnsatisfiedLinkError: /tmp/libtmp3063431695356017359libjunixsocket-native-2.2.0.so: /tmp/libtmp3063431695356017359libjunixsocket-native-2.2.0.so: failed to map segment from shared object
                at java.lang.ClassLoader$NativeLibrary.load(Native Method)
                at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1934)
                at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1817)
                at java.lang.Runtime.load0(Runtime.java:810)
                at java.lang.System.load(System.java:1088)
                at org.newsclub.net.unix.NativeLibraryLoader$ClasspathLibraryCandidate.load(NativeLibraryLoader.java:158)
                at org.newsclub.net.unix.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:235)
                ... 33 more
21:05:03.433 [INFO] [com.bmuschko.gradle.docker.shaded.org.apache.http.impl.execchain.RetryExec] Retrying request to {}->unix://localhost:80
kohlschuetter commented 3 years ago

This is the same issue as #81. See #81 for a workaround that you can apply on these old Linux distributions.