I just wasted two days. I am working on a desktop application in JAVA. It needs to sniff web proxy settings from the Window’s registry (and some day other platform specific locations). I decided to use JNI  to do this. Everything worked like a charm in my sandbox JAVA application. I then embarked on moving it to and OSGI bundle. When I ran the thing I received a java.lang.UnsatisfiedLinkError. WTF!! WHY!!Â
When I debugged my call to System.load(“somedll”) worked, but an exception was triggered when I invoked the native method. I then thought well maybe its and OSGI thing.  After some Google-ing I found a few write ups on how to tweak the manifest to load the system specific library.  I tried effing with the manifes eight ways from Sunday, but still no workie. I then came across a forum where someone had the same issue I did and they eventually discovered that that they had renamed their JAVA class, but did not regenerate the JNI lib.  It then dawned on me that I had refactored my JAVA class in to a new package, but did not update the generated .h file. Â
The morale of the story is if your JNI call works outside of OSGI, but then stops working when you move it in to OSGI; ask yourself “did I refactor this thing when I moved it in to a bundle?”Â