Binding with JNI

I am developing a binding that use jar with JNI binding. When I run methods on the JNI I get an error:

java.lang.ExceptionInInitializerError: Native Library … already loaded in another classloader

Any idea how to work around this type of problem?

I’ll answer this myself in case it is of interest for someone. This happens when openhab reloads the binding jar file from /usr/share/openhab2/addons/ if it was changed since last time. No real way of avoiding this, but also just a problem when dumping snapshot jars in “production” openhab instance.