简体   繁体   中英

Java + Raspberry Pi + SQlite = NoClassDefFoundError

I'm trying to run my new application on my Raspberry Pi. It should connect to a sqlite-database. sqlite-jdbc-3.8.11.2.jar is added to the build-path. On my other Linux it works very well, but on the Raspberry it doesn't. I downloaded libsqlitejdbc.so from https://bitbucket.org/xerial/sqlite-jdbc/issues/79/compile-for-arm , because I read, that this is necessary to run it on the Pi. The file libsqlitejdbc.so is in /home/pi/workspace/data/ The relevant code is:

Class.forName("org.sqlite.JDBC");
System.loadLibrary("sqlitejdbc");
connection = DriverManager.getConnection("jdbc:sqlite:"+DB_PATH);

When I run it, I get a NoClassDefFoundError caused by line 2:

java.lang.NoClassDefFoundError: org/sqlite/NativeDB
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1968)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1893)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1883)
    at java.lang.Runtime.loadLibrary0(Runtime.java:849)
    at java.lang.System.loadLibrary(System.java:1088)
    at kanu.kayapp.DBController.<init>(DBController.java:46)
    at kanu.kayapp.DBController.<clinit>(DBController.java:26)
    at kanu.kayapp.Server.parseMessage(Server.java:210)
    at kanu.kayapp.Server.mainLoop(Server.java:145)
    at kanu.kayapp.Main.main(Main.java:34)
Caused by: java.lang.ClassNotFoundException: org.sqlite.NativeDB
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 11 more

I tried the following things:

$ export CLASSPATH="/home/pi/workspace/data/"
$ export LD_LIBRARY_PATH="/home/pi/workspace/data/"

I have managed solving the JDBC Sqlite problems on Raspberry Pi using the .jar file here:

https://github.com/JeffLeFoll/IoT-Challenge-Capgemini/commit/60c86ee680c275b085a5af9a79412eefc1ae8c74

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM