bodensx / jnaerator

Automatically exported from code.google.com/p/jnaerator
0 stars 0 forks source link

JNAerator fails to load native binary (e.g. used with JavaCL) inside an OSGI bundle #61

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. put native binary (eg. libOpenCL) into an OSGI bundle (using
Bundle-NativeCode header)
2. Include a nativelib4java (eg. JavaCL) in project and try to init it (eg.
JavaCL.listPlatforms)
3. deploy bundle and start it

What is the expected output? What do you see instead?
The JNAerator magic should happen so the native library can be used by the
bundles Java code. Instead JNAerator fails to extract the libraries binary,
see stack-trace below.

What version of the product are you using? On what operating system?
1.0-SNAPSHOT, Ubuntu Linux 9.10 (amd64)

Additional information: stack trace when bundle activation fails:

ERROR: Failed to extract library OpenCL
java.io.IOException: Cannot list contents of
bundle://14.0:1/libraries/Linux-amd64
    at com.ochafik.net.URLUtils.listFiles(URLUtils.java:58)
    at
com.ochafik.lang.jnaerator.runtime.LibraryExtractor.getLibraryPath(LibraryExtrac
tor.java:95)
    at
com.nativelibs4java.opencl.library.OpenCLLibrary.<clinit>(OpenCLLibrary.java:24)
    at com.nativelibs4java.opencl.JavaCL.<clinit>(JavaCL.java:44)
    at
org.wulff.cv.openclservice.impl.OpenCLServiceImpl.activate(OpenCLServiceImpl.jav
a:15)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at
org.apache.felix.scr.impl.helper.BaseMethod.invokeMethod(BaseMethod.java:213)
    at org.apache.felix.scr.impl.helper.BaseMethod.access$500(BaseMethod.java:38)
    at
org.apache.felix.scr.impl.helper.BaseMethod$Resolved.invoke(BaseMethod.java:542)
    at org.apache.felix.scr.impl.helper.BaseMethod.invoke(BaseMethod.java:434)
    at
org.apache.felix.scr.impl.helper.ActivateMethod.invoke(ActivateMethod.java:138)
    at
org.apache.felix.scr.impl.manager.ImmediateComponentManager.createImplementation
Object(ImmediateComponentManager.java:226)
    at
org.apache.felix.scr.impl.manager.ImmediateComponentManager.createComponent(Imme
diateComponentManager.java:118)
    at
org.apache.felix.scr.impl.manager.AbstractComponentManager$Unsatisfied.activate(
AbstractComponentManager.java:991)
    at
org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(Abst
ractComponentManager.java:298)
    at
org.apache.felix.scr.impl.manager.AbstractComponentManager$1.doRun(AbstractCompo
nentManager.java:138)
    at
org.apache.felix.scr.impl.ComponentActivatorTask.run(ComponentActivatorTask.java
:67)
    at
org.apache.felix.scr.impl.ComponentActorThread.run(ComponentActorThread.java:96)
    at java.lang.Thread.run(Thread.java:636)
[SCR Component Actor] ERROR cv-opencl-service-impl -
[org.wulff.cv.openclservice.impl] The activate method has thrown an exception
java.lang.UnsatisfiedLinkError: com.sun.jna.Native.sizeof(I)I
    at com.sun.jna.Native.sizeof(Native Method)
    at com.sun.jna.Native.<clinit>(Native.java:109)
    at com.sun.jna.NativeLibrary.<clinit>(NativeLibrary.java:60)
    at
com.nativelibs4java.opencl.library.OpenCLLibrary.<clinit>(OpenCLLibrary.java:25)
    at com.nativelibs4java.opencl.JavaCL.<clinit>(JavaCL.java:44)
    at
org.wulff.cv.openclservice.impl.OpenCLServiceImpl.activate(OpenCLServiceImpl.jav
a:15)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at
org.apache.felix.scr.impl.helper.BaseMethod.invokeMethod(BaseMethod.java:213)
    at org.apache.felix.scr.impl.helper.BaseMethod.access$500(BaseMethod.java:38)
    at
org.apache.felix.scr.impl.helper.BaseMethod$Resolved.invoke(BaseMethod.java:542)
    at org.apache.felix.scr.impl.helper.BaseMethod.invoke(BaseMethod.java:434)
    at
org.apache.felix.scr.impl.helper.ActivateMethod.invoke(ActivateMethod.java:138)
    at
org.apache.felix.scr.impl.manager.ImmediateComponentManager.createImplementation
Object(ImmediateComponentManager.java:226)
    at
org.apache.felix.scr.impl.manager.ImmediateComponentManager.createComponent(Imme
diateComponentManager.java:118)
    at
org.apache.felix.scr.impl.manager.AbstractComponentManager$Unsatisfied.activate(
AbstractComponentManager.java:991)
    at
org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(Abst
ractComponentManager.java:298)
    at
org.apache.felix.scr.impl.manager.AbstractComponentManager$1.doRun(AbstractCompo
nentManager.java:138)
    at
org.apache.felix.scr.impl.ComponentActivatorTask.run(ComponentActivatorTask.java
:67)
    at
org.apache.felix.scr.impl.ComponentActorThread.run(ComponentActorThread.java:96)
    at java.lang.Thread.run(Thread.java:636)

Original issue reported on code.google.com by bwu...@uos.de on 14 Apr 2010 at 10:56

GoogleCodeExporter commented 8 years ago
Hi,

The "ERROR: Failed to extract library OpenCL" error might not be the issue, as 
it's just an alarmist message 
(does need to be toned down :-)) displayed in case the runtime fails to extract 
bundled libraries (in the 
OpenCL4Java case, there is no such library, we always use the system's).

What does crash your program is the exception that follows : 
"java.lang.UnsatisfiedLinkError: com.sun.jna.Native.sizeof(I)I"

This means that the JNA native library wasn't extracted properly (JNA has its 
own extraction mechanism, which 
I'm not very familiar with).

Original comment by olivier.chafik@gmail.com on 16 Apr 2010 at 1:15

GoogleCodeExporter commented 8 years ago
In deed the problems was caused by an older version of the jnidispatch library 
(that
JNA relies on) that must have sliped into my systems library path possibly with
another component I use.

Fortunately, since the project lives in OSGi, libraries in different versions 
can be
provided for each bundle :-)

Original comment by bwu...@uos.de on 20 Apr 2010 at 11:27

GoogleCodeExporter commented 8 years ago

Original comment by olivier.chafik@gmail.com on 11 Oct 2010 at 1:49