Following this question.
I'm using Bundle-NativeCode
header to specify native libraries that should be loaded by plugin.
It works fine when the libraries reside in the same plugin as the code that loads them (System.loadLibrary
). However, when I try to put the libraries in a separate plugin fragment, System.loadLibrary
fails with UnsatisfiedLinkError
.
The manifest of the host plugin (when the libraries in the host plugin):
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Jni
Bundle-SymbolicName: com.ebar.workmode.jni
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: com.ebar.workmode.jni.Activator
Bundle-Vendor: EBAR
Require-Bundle: org.eclipse.core.runtime,
org.slf4j.api,
javax.inject;bundle-version="1.0.0",
com.ebar.workmode.contracts;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Export-Package: com.ebar.workmode.jni
Eclipse-ExtensibleAPI: true
Bundle-NativeCode: native/ipcs.dll ; native/ipcs_tcpip_plugin.dll ; osname=win32
The manifest of the plugin fragment:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: workmode JNI win x86
Bundle-SymbolicName: com.ebar.workmode.jni.windows.x32;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: EBAR
Fragment-Host: com.ebar.workmode.jni;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-NativeCode: native/ipcs_tcpip_plugin.dll ; native/ipcs.dll ; osname=win32
Activator.start
of the host plugin:
@Override
public void start(BundleContext bundleContext) throws Exception {
System.loadLibrary("ipcs");
System.loadLibrary("ipcs_tcpip_plugin");
}
The error that I get when I remove the Bundle-NativeCode
header from the host plugin:
java.lang.UnsatisfiedLinkError: no ipcs in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at com.ebar.workmode.jni.Activator.start(Activator.java:34)
at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:771)
at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:1)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:764)
... 102 more
- The plugin fragment is added to the product
- The plugin fragment doesn't show any error in target platform state tab
- The native folder of plugin fragment is included in binary build (in
build.properties
)
Why isn't it working and how to make the host plugin to load the native libraries from the plugin fragment? Or alternatively, is there a way to make the plugin fragment to load its libraries?