I am getting the unsatisfied link error when I try to run the web-app.
Suppressed: java.lang.UnsatisfiedLinkError: libXXXX.so: cannot open shared object file: No such file or directory at deployment.ttt.war//com.sun.jna.Native.open(Native Method) at deployment.ttt.war//com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:191) ... 74 more Suppressed: java.lang.UnsatisfiedLinkError: libXXXX.so: cannot open shared object file: No such file or directory at deployment.ttt.war//com.sun.jna.Native.open(Native Method) at deployment.ttt.war//com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:204) ... 74 more Suppressed: java.io.IOException: Native library (linux-x86-64/libXXXX.so) not found in resource path (/opt/jboss-eap-7.3/jboss-modules.jar) at deployment.ttt.war//com.sun.jna.Native.extractFromResourcePath(Native.java:1095) at deployment.ttt.war//com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:275) ... 74 more
- I have created the function which loads the native library stored at “/home/libraryFiles”, using JNA.
- I have stored all of my libXXXX.so files at “/home/libraryFiles”.
- I have exporting my war file from eclipse in windows and deploying it on the jboss server on redhat linux.
This is my function :
public class function1(){ public interface CLibrary extends Library { public int method1(String message); } public int execute (String param) throws Exception{ NativeLibrary.addSearchPath("libXXXX", "home/libraryFiles"); CLibrary pLib =(CLibrary)Native.loadLibrary("XXXX",CLibrary.class); return pLib.method1(param); }
}
I am mapping url through rest controller to execute
new function1().execute("aaaaaaa");
I have also tried setting jna.library.path & java.library.path to “home/libraryFiles”, but of no use. (using system.setProperty())
I also tried set $LD_LIBRARY_PATH=home/libraryFiles
but still no good.
Seems like my web-app is not able to point out of the default resource path “/opt/jboss-eap-7.3/jboss-modules.jar”
Any help is welcoming.
PS : I tried the same function/code on my windows PC, its working fine. I don’t know why its not working on redhat linux.
Thanks in Advance.
Advertisement
Answer
The addSearchPath()
method is specific to a library, and the additional path(s) are stored in a map with the library name as the key.
The loadLibrary()
method checks that map using the library name.
You have used differing strings as the key to store the path and retrieve it:
NativeLibrary.addSearchPath("libXXXX", "home/libraryFiles"); CLibrary pLib =(CLibrary)Native.loadLibrary("XXXX",CLibrary.class);
You should either change “libXXXX” to “XXXX” in the first line (probably the preferred style) or do the reverse in the second line to match.
As noted in the comments, you also must be careful with relative vs. absolute file paths and directory permissions.