'Java application is not able to load the native library of sqlite in ubuntu
I have a java application where it tries to connect to sqlite3 db. But it is not able to connect to the sqlite3 and throws the below error. The application is deployed on an ubuntu server. Sqlite3 is installed manually on the server.
Java environment versions are as below. openjdk version "1.8.0_312" OpenJDK Runtime Environment (build 1.8.0_312-8u312-b07-0ubuntu1~18.04-b07) OpenJDK 64-Bit Server VM (build 25.312-b07, mixed mode) Ubuntu version is 20.04 lts. sqlite3 version is 3.11.0 2016-02-15 17:29:24 sqlite-jdbc version: '3.34.0'
Error is
Failed to load native library:sqlite-3.34.0-35fd940a-3fda-4c48-862f-ac8a88265940-libsqlitejdbc.so. osinfo: Linux/x86_64
java.lang.UnsatisfiedLinkError: /tmp/skynet/allocator_model_testjavamodel/sqlite-3.34.0-35fd940a-3fda-4c48-862f-ac8a88265940-libsqlitejdbc.so: /tmp/skynet/allocator_model_testjavamodel/sqlite-3.34.0-35fd940a-3fda-4c48-862f-ac8a88265940-libsqlitejdbc.so: failed to map segment from shared object
java.sql.SQLException: Error opening connection
at org.sqlite.SQLiteConnection.open(SQLiteConnection.java:239)
at org.sqlite.SQLiteConnection.<init>(SQLiteConnection.java:61)
at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:28)
at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:21)
at org.sqlite.JDBC.createConnection(JDBC.java:115)
at org.sqlite.JDBC.connect(JDBC.java:90)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:270)
at Utility.DbConnection.connect(DbConnection.java:16)
at Utility.RevisionTask.run(RevisionTask.java:31)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
Caused by: java.lang.Exception: No native library found for os.name=Linux, os.arch=x86_64, paths=[/org/sqlite/native/Linux/x86_64:/home/manajit/opt/sqlite/lib:/usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib]
at org.sqlite.SQLiteJDBCLoader.loadSQLiteNativeLibrary(SQLiteJDBCLoader.java:367)
at org.sqlite.SQLiteJDBCLoader.initialize(SQLiteJDBCLoader.java:67)
at org.sqlite.core.NativeDB.load(NativeDB.java:63)
at org.sqlite.SQLiteConnection.open(SQLiteConnection.java:235)
The directory and the file which it is trying to find are very well present in the server. I made sure all the permissions to the directory are given to the user who runs the application.
Note that the same java application is running fine on another server where the ubuntu version is 16.04 lts. The java version installed on this another server is openjdk version "1.8.0_292" OpenJDK Runtime Environment (build 1.8.0_292-8u292-b10-0ubuntu1~16.04.1-b10) OpenJDK 64-Bit Server VM (build 25.292-b10, mixed mode).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
