kohlschutter / junixsocket

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

Not able to make mysql socket connections on OEL 7 #44

Closed manasshukla closed 6 years ago

manasshukla commented 6 years ago

Not able to make mysql socket connections on OEL7, Getting the below error

Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_66] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_66] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_66] at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_66] at org.newsclub.net.unix.NativeUnixSocket.(NativeUnixSocket.java:35) ~[junixsocket-common-2.0.4.jar:?] at org.newsclub.net.unix.AFUNIXSocket.(AFUNIXSocket.java:36) ~[junixsocket-common-2.0.4.jar:?] at org.newsclub.net.unix.AFUNIXSocket.newInstance(AFUNIXSocket.java:54) ~[junixsocket-common-2.0.4.jar:?] at org.newsclub.net.unix.AFUNIXSocket.connectTo(AFUNIXSocket.java:81) ~[junixsocket-common-2.0.4.jar:?] at org.newsclub.net.mysql.AFUNIXDatabaseSocketFactory.connect(AFUNIXDatabaseSocketFactory.java:58) ~[junixsocket-mysql-2.0.4.jar:?] at com.mysql.jdbc.MysqlIO.(MysqlIO.java:300) ~[mysql-connector-java-5.1.39.jar:5.1.39] at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2251) ~[mysql-connector-java-5.1.39.jar:5.1.39] at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2284) ~[mysql-connector-java-5.1.39.jar:5.1.39] at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2083) ~[mysql-connector-java-5.1.39.jar:5.1.39] at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:806) ~[mysql-connector-java-5.1.39.jar:5.1.39] at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:47) ~[mysql-connector-java-5.1.39.jar:5.1.39] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_66] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_66] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_66] at java.lang.reflect.Constructor.newInstance(Constructor.java:422) ~[?:1.8.0_66] at com.mysql.jdbc.Util.handleNewInstance(Util.java:404) ~[mysql-connector-java-5.1.39.jar:5.1.39] ... 11 more Caused by: java.lang.UnsatisfiedLinkError: /tmp/libjunixsocket-native-2.0.4623683371284803817.so: /tmp/libjunixsocket-native-2.0.4623683371284803817.so: failed to map segment from shared object: Operation not permitted at java.lang.ClassLoader$NativeLibrary.load(Native Method) ~[?:1.8.0_66] at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1938) ~[?:1.8.0_66] at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1821) ~[?:1.8.0_66] at java.lang.Runtime.load0(Runtime.java:809) ~[?:1.8.0_66] at java.lang.System.load(System.java:1086) ~[?:1.8.0_66] at org.newsclub.net.unix.NarSystem.loadLibrary(NarSystem.java:39) ~[junixsocket-native-common-2.0.4.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_66] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_66] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_66] at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_66]

On OEL 6 we are able to get the mysql socket connections.

manasshukla commented 6 years ago

This was becuase the library tries to unpack and load the JNI library from /tmp dir. OEL 7 does not support loading of libraries from /tmp directories. To resolve this we have to set the directory from which the libraries would be loaded explicitly. To do this just pass the following system property : -Djava.io.tmpdir=<<location where .so has to be unpacked>>