Pigelvy
Pigelvy

Reputation: 616

EXCEPTION_ACCESS_VIOLATION when accessing LeapMotion API within OSGi

I'm trying to use the new Leap Motion sensor within OSGi (Felix) but I end up with an EXCEPTION_ACCESS_VIOLATION.

In my manifest I declare the Bundle-NativeCode such as

<Bundle-NativeCode>
   x86/Leap.dll;x86/LeapJava.dll;osname=win32;processor=x86
</Bundle-NativeCode>

Of course:

After decompiling the Leap Motion jar, I saw that LeapJava.dll is the only library that is loaded (using System.loadLibrary("LeapJava")). Is it possible that they do not load their other library correctly?

Any idea?

Edit 1: As introduced by a Felix developer, this link may be helpful http://wiki.osgi.org/wiki/Dependencies_In_Native_Code

Upvotes: 2

Views: 304

Answers (1)

Pigelvy
Pigelvy

Reputation: 616

With the assistance of Neil Bartlett, and the reading of Dependencies_In_Native_Code, I eventually managed to make the Leap Motion work in OSGi.

Here's what I did:

  • Both Leap.dll and LeapJava.dll are in the x86 folder in my bundle (I'm on WindowsXP 32bits)
  • Added the following to my META-INF/MANIFEST.MF:

    <Bundle-NativeCode>
        x86/Leap.dll;x86/LeapJava.dll;processor=x86;osname=win32
    </Bundle-NativeCode>
    
  • In my code, before creating the com.leapmotion.leap.Controller, I called System.loadLibrary("Leap") to pre-load the Leap.dll library. Following the rules explained in Dependencies_In_Native_Code, I only have to pre-load Leap.dll because LeapJava.dll is loaded by Leap Java API.

Upvotes: 2

Related Questions