[SOLVED] Error when Adding Bluetooth BlueZ Adapter: "BlueZ JNI connection cannot be established."

Hello guys,

I’m having a little trouble regarding the Bluetooth Binding which I want to use for presence detection in combination with a BLE beacon. Installing the Binding was no problem, but as soon as I want to add a Bluetooth BlueZ Adapter via MAC the following error is logged (doesn’t matter if I add the thing via PaperUI or a *.things file):

2020-03-23 12:47:35.375 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.initialize()' on 'org.openhab.binding.bluetooth.bluez.handler.BlueZBridgeHandler@6653a': BlueZ JNI connection cannot be established.
java.lang.IllegalStateException: BlueZ JNI connection cannot be established.
        at org.openhab.binding.bluetooth.bluez.handler.BlueZBridgeHandler.initialize(BlueZBridgeHandler.java:99) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_222]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_222]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_222]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_222]
        at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
        at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_222]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_222]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_222]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]
Caused by: java.lang.UnsatisfiedLinkError: tinyb.BluetoothManager.getNativeAPIVersion()Ljava/lang/String;
        at tinyb.BluetoothManager.getNativeAPIVersion(Native Method) ~[?:?]
        at tinyb.BluetoothManager.getBluetoothManager(BluetoothManager.java:304) ~[?:?]
        at org.openhab.binding.bluetooth.bluez.handler.BlueZBridgeHandler.initialize(BlueZBridgeHandler.java:94) ~[?:?]
        ... 10 more
2020-03-23 12:47:35.407 [ERROR] [core.thing.internal.ThingManagerImpl] - Exception occurred while initializing handler of thing 'bluetooth:bluez:5494ac43': BlueZ JNI connection cannot be established.
java.lang.IllegalStateException: BlueZ JNI connection cannot be established.
        at org.openhab.binding.bluetooth.bluez.handler.BlueZBridgeHandler.initialize(BlueZBridgeHandler.java:99) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_222]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_222]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_222]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_222]
        at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
        at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_222]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_222]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_222]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]
Caused by: java.lang.UnsatisfiedLinkError: tinyb.BluetoothManager.getNativeAPIVersion()Ljava/lang/String;
        at tinyb.BluetoothManager.getNativeAPIVersion(Native Method) ~[?:?]
        at tinyb.BluetoothManager.getBluetoothManager(BluetoothManager.java:304) ~[?:?]
        at org.openhab.binding.bluetooth.bluez.handler.BlueZBridgeHandler.initialize(BlueZBridgeHandler.java:94) ~[?:?]
        ... 10 more

During my research I stumbled across this topic, which seems to deal with the same problem. However, the solution mentioned there is not viable for me, since I don’t have the files they mention on my system. I’ve checked every folder listed in the Repository Installation column from the docs.

Since they mention the files should be there if the bluetooth.bluez extension is installed, I think I’m missing that. This lead to another problem. Searching for the extension in PaperUI leads to no results and manually adding bluetooth.bluez to my addons.cfg file threw the following error:

2020-03-23 13:00:41.719 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing 'openhab-binding-bluetooth.bluez'

This is where I stopped, since I couldn’t figure out how to install that extension even though I researched for hours. Any help here would be appreciated.

Some additional info:
I’m running openHab v2.5.3 natively (not Docker or VM) on a Rasperry Pi 3 Model B+ with Raspbian Lite Buster. I have downgraded the bundled BlueZ v5.50 to the latest supported v5.47 following this tutorial. Running sudo systemctl status bluetooth yields this result:

● bluetooth.service - Bluetooth service
   Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2020-03-22 22:54:32 CET; 13h ago
     Docs: man:bluetoothd(8)
 Main PID: 14149 (bluetoothd)
   Status: "Running"
    Tasks: 1 (limit: 2200)
   Memory: 464.0K
   CGroup: /system.slice/bluetooth.service
           └─14149 /usr/libexec/bluetooth/bluetoothd

Mar 22 22:54:32 vlntn-raspi systemd[1]: Starting Bluetooth service...
Mar 22 22:54:32 vlntn-raspi bluetoothd[14149]: Bluetooth daemon 5.47
Mar 22 22:54:32 vlntn-raspi systemd[1]: Started Bluetooth service.
Mar 22 22:54:32 vlntn-raspi bluetoothd[14149]: Starting SDP server
Mar 22 22:54:32 vlntn-raspi bluetoothd[14149]: Bluetooth management interface 1.14 initialized
Mar 22 22:54:32 vlntn-raspi bluetoothd[14149]: Failed to set privacy: Rejected (0x0b)

Running sudo hcitool lescan lists the devices I want to add and running hcitool dev returns the MAC of my adapter, so I assume the Bluetooth module is working fine.

Im having the same issue. I tried MANY things today with no luck and actually fear I messed things up on my install since I did so many things!

I tried guides like: 3rd Party Bluetooth Binding. Beta testers needed and reelyActive Smart Spaces Revisited but all lead to dead-ends with the bluetooth device never showing up in the inbox and errors in the openhab logs.

Any help would be appreciated (BTW I have a Raspberry Pi 4 and am trying to use the builtin bluetooth, with openhab 2.5.2)

Per (SOLVED) BlueZ JNI connection cannot be established. OpenHab 2.5 + Bluez 5.47 on Rasp I tried coping those 2 files but same error:

sudo cp /etc/openhab2/libjavatinyb.so /usr/lib/jvm/java-8-openjdk-armhf/jre/lib/arm
sudo cp /etc/openhab2/libtinyb.so /usr/lib/jvm/java-8-openjdk-armhf/jre/lib/arm

Have you tried reading this?

1 Like

Thanks. Following these steps solved the issue for me. Although I had to start with a clean install of openHABian.