Jdbc sqlite does not work

I’m trying to get Openhab running again after a corrupted disk. I used the latest openhabian so I now have openhab 4.0.1
Unfortunatelly jdbc persistence with sqlite does not work anymore. I get tons of messages like this:

2023-08-12 09:15:00.418 [INFO ] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection: Driver is available::Yank setupDataSource
2023-08-12 09:15:00.420 [WARN ] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection: failed to open connection: Failed to initialize pool: 'void org.sqlite.core.NativeDB._open_utf8(byte[], int)'
2023-08-12 09:15:00.422 [INFO ] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection: Driver is available::Yank setupDataSource
2023-08-12 09:15:00.423 [WARN ] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection: failed to open connection: Failed to initialize pool: 'void org.sqlite.core.NativeDB._open_utf8(byte[], int)'
2023-08-12 09:15:00.425 [WARN ] [jdbc.internal.JdbcPersistenceService] - JDBC::store: No connection to database. Cannot persist state '22.9' for item 'Temperatur_Terrasse (Type=NumberItem, State=22.9, Label=Terrasse, Category=temperatur
e, Tags=[Measurement, Temperature], Groups=[Temperaturen, Temp_aussen, Terrasse])'! Will retry connecting to database when error count:0 equals errReconnectThreshold:0

There is no difference if I use the old persistence db file or not.

I tried now three different things:
New install of OH4 with my config backup (initial.zip in /boot)
New install of OH3 with my config backup (initial.zip in /boot)
New install of OH4 with clean config and then installing jdbc sqlite, add mqtt binding and some things/items and add them to persistance (via the new GUI)

In all cases I used the latest openhabian image on a RPI4 and in all cases I get the same error messages.
Can this be related to the Java17 update? Does jdbc sqlite work for anyone with Java 17?

I don’t know if this will fix your issue, but you could try this version using the latest SQLite JDBC driver:

You would need to:

  • Uninstall the official JDBC persistence add-on.
  • Rename sqlite-jdbc-3.42.0.0.jar to sqlite-jdbc.jar.
  • Drop both files in your addons directory.

See also:

Can I use that with OH3 as well? I would like to get the system running before upgrading as my backup is from a OH3 system.
Meanwhile I found something else in the syslog:

openhabian karaf[577]: Failed to load native library:sqlite-3.40.0.0-052bfca4-00a0-416f-b5ac-b5e9d5232416-libsqlitejdbc.so. osinfo: Linux/aarch64
openhabian karaf[577]: java.lang.UnsatisfiedLinkError: /var/lib/openhab/tmp/sqlite-3.40.0.0-052bfca4-00a0-416f-b5ac-b5e9d5232416-libsqlitejdbc.so: /var/lib/openhab/tmp/sqlite-3.40.0.0-052bfca4-00a0-416f-b5ac-b5e9d5232416-libsqlitejdbc.so: wrong ELF class: ELFCLASS64 (Possible cause: architecture word width mismatch)

I definitively installed a 32bit openhabian. I uninstalled the jdbc sqlite addon, removed the file and reinstalled, but the error persists.

$ file /var/lib/openhab/tmp/sqlite-3.40.0.0-052bfca4-00a0-416f-b5ac-b5e9d5232416-libsqlitejdbc.so
/var/lib/openhab/tmp/sqlite-3.40.0.0-052bfca4-00a0-416f-b5ac-b5e9d5232416-libsqlitejdbc.so: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, BuildID[sha1]=7ff423e65a2507864f56df7200190baaaa671712, stripped

It looks like the libsqlitejdbc.so that is installed in your case is
org/sqlite/native/Linux/aarch64/libsqlitejdbc.so
instead of
org/sqlite/native/Linux/armv7/libsqlitejdbc.so

both files are included in the jar file.

Sounds like: After updating 32 bit Raspi OS Pi 4 is on 64bit kernel · Issue #1795 · raspberrypi/firmware · GitHub

The current OS you installed is Bullseye or an other version ( cat /etc/os-release ) ?
What is being shown by: uname -a

Thanks for the tip!

$ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
NAME="Raspbian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
$ uname -a
Linux openhabianpi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr  3 17:24:16 BST 2023 aarch64 GNU/Linux
$ getconf LONG_BIT
32

After adding arm_64bit=0 to config.txt I’m back to

Linux openhabianpi 6.1.21-v7l+ #1642 SMP Mon Apr  3 17:22:30 BST 2023 armv7l GNU/Linux

and sqlite works again.
Now is this a bug in Java or Openhab?

1 Like

The OS was upgraded to 64 bit.
The openhabian detection of the architecture may not work correct or may not yet be prepared to detect this case.
I think others also had this oroblem but havent seen that mentuoned anywhere yet.

I think this should be added to the FAQ

:+1: Are you on 4.0 now, or 3.4? If you are on 4.0 it would be highly appreciated if you could still give the 3.42 update a test run, so we can finally get this update merged. 3.41.2.2 contains an important security fix, but so far I have not been able to find anyone to give it a try (since I’m not running SQLite myself).

I’m back on 3.4 sorry. It took my way too long to get my system back up and running. Not sure when I find the time to upgrade to 4.0

I’m on 4.0.3 currently and it is still not working, using apt packages.

root@rpi4:/var/log#openhab-cli info

Version:     4.0.3 (Build)

Oct 10 20:03:24 rpi4 karaf[23783]: Failed to load native library:sqlite-3.40.0.0-17b13633-8517-43a3-a52f-99169db5ab4d-libsqlitejdbc.so. osinfo: Linux/aarch64

I originally mentioned this in July. You might want to add a release note or FAQ for a workaround. Anyone that upgrades a raspberry pi4 is goint to hit the problem if they use sqlite for persistence. More people are likely to upgrade as time goes on.

I think there may also be something similar going on with one of the jni’s for karaf. When I go into the console (after the 64bit upgrade) I get the following warning, which doesn’t seem to affect anything but it does seem related to the 64bit kernel changes…


root@rpi4:/var/log#openhab-cli console

Logging in as openhab
Password:
Failed to load native library:jansi-2.4.0-d4e0b38880065a7e-libjansi.so. osinfo: Linux/arm
java.lang.UnsatisfiedLinkError: /var/lib/openhab/tmp/jansi-2.4.0-d4e0b38880065a7e-libjansi.so: /var/lib/openhab/tmp/jansi-2.4.0-d4e0b38880065a7e-libjansi.so: cannot open shared object file: No such file or directory

                           _   _     _
 ____

In your other thread you wrote that you have the problem with 3.4.4-2 so that one is even witout upgrade to 4.0.
Question: your 3.4.4-2 and 4.0 instance are/were based on 64 bit ?
As far as I understand the problem initially described here was that the OS was upgraded to 64 bit while 32 bit initially was installed. Changing the boot/kernel parameter made sure that the host was booted in 32 bit mode.
In your case as far as I understand you initially installed 64 bit, right ?

Yes the 3.4.4-2 and 4.0.3 were/are on 64bit at the time it stopped working.

I was on 3.4.4-2 as 32bit and everything was fine, and did a general system apt update / upgrade, which (unknown to me at the time) enabled the kernel from 32 bits to 64bits as the linked article says. After that jdbc never worked again because the library was wrong. Subsequent to that I finally got around to updating OH to 4.0.3 so I was just reporting that the issue is the same.

There are possible other libraries as I mentioned, unless that error from karaf is supposed to happen.

Finally fixed or workedaround.
See Openhab installs 64 bit jna lib on 32 bit raspberry pi and breaks jdbc sqlite - #2 by splatch