Reputation: 290
I have problem when loading shared libraries (JNI) from java class on Ubuntu operator system
Exception in thread "main" java.lang.UnsatisfiedLinkError: /opt/ETcpsdk/lib/linux-x86_64/libjcryptoki.so: libcryptoki.so: cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1965)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1890)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1880)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1088)
at tutorialjni.Test.<clinit>(Test.java:7)
- Test.java
package tutorialjni;
public class Test {
// Load an external library, called "jcryptoki"
static {
System.loadLibrary("jcryptoki");
}
public static void main(String[] args) {
System.out.println(System.getProperty("java.library.path"));
}
}
- LD_LIBRARY_PATH was allocated in /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
JAVA_HOME="/opt/jdk1.7.0_75"
LD_LIBRARY_PATH="/opt/ETcpsdk/lib/linux-x86_64:/opt/ETcpsdk/lib/"
And I own ETcpsdk folder.
libcryptoki.so put in /opt/ETcpsdk/lib/linux-x86_64/libcryptoki.so
Run file libcryptoki.so command
libjcryptoki.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped
- JDK version:
java version "1.7.0_75"
Java(TM) SE Runtime Environment (build 1.7.0_75-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode)
- Ubuntu:
Distributor ID: Ubuntu
Description: Ubuntu 14.04.2 LTS
Release: 14.04
Codename: trusty
I added library directory to ldconfig cache
Can you help me?
Upvotes: 6
Views: 8745
Reputation: 103
If you encounter this from Linux, there usually 3 main reasons:
Solution: Set your path variable at .bashrc so that it loads on starup. Reboot Linux or run . ~/.bashrc.
Solution: Check your library file if it exists as link and whether it points to a valid file.
I hit this error when my web app was started in Linux by user logged in with insufficient access rights. This error usually followed by other errors / exceptions, especially from your application server i.e for Tomcat:
org.apache.catalina.LifecycleException: Failed to initialize component ...
or
org.hibernate.engine.jdbc.internal.LobCreatorBuilder - HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
Solution: Stop your web / application server current instance. Login with super user or those with sufficient access rights i.e root Restart your server or call previous function again.
Upvotes: 1
Reputation: 290
I got this problem because my shared libraries depends on another shared library which works improperly.
Upvotes: 2