2

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:

  • A simple program with the same libraries outside OSGi works fine
  • the two libraries are in my bundle in the 'x86' folder
  • "osname=win32;processor=x86" works for me (has been tested with other bunbles

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

Pigelvy
  • 606
  • 6
  • 17
  • I'm not sure what osgi is, so there is my problem, but what IDE do you use? Do you have those problems while developing in your IDE or do you have those problems after creating a runnable .jar file? – Loki Jul 25 '13 at 13:20
  • @Loki Pigelvy has tried a simple program and it works. There is no problem with IDE (currently Intellij) but check http://www.osgi.org. – chepseskaf Jul 25 '13 at 13:33
  • Already answered this question on the mailing list, not sure whether I should answer it here as well! – Neil Bartlett Jul 25 '13 at 18:18
  • @Neil not everybody reads the mailing list ... Not even know on what mailing list? Could you paste the answer here? – Peter Kriens Jul 26 '13 at 06:26
  • I posted on both places. I was waiting to get an answer before synchronizing both posts... I'm currently trying to pre-load both libraries while having them install on the %Path%. I'll keep you posted. – Pigelvy Jul 26 '13 at 10:31

1 Answers1

2

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.

Community
  • 1
  • 1
Pigelvy
  • 606
  • 6
  • 17
  • to complete my answer... It also worked when I added both libraries to the Windows execution %Path%. With this technique I did not have to pre-load Leap.dll (the libraries were not in my OSGi bundle). – Pigelvy Jul 29 '13 at 13:10