Skip to content

IOException when loading a native library inside an OSGI bundle using jna.library.path #153

@ochafik

Description

@ochafik

What steps will reproduce the problem?

  1. Create an OSGi bundle that uses a jnaerated CustomLibrary.INSTANCE
  2. Run OSGi container with path to native library (-Djna.library.path=lib)
  3. Deploy and start the custom bundle

What is the expected output? What do you see instead?
The JNAerated code should run without problem as according to the documentation jna.library.path is where libraries are looked for at run-time. Instead an IOException is thrown by the call LibraryExtractor.getLibraryPath()

What version of the product are you using? On what operating system?
maven-jnaerator-plugin 0.9.5 on Windows 7

Is the problem still present in the latest SVN version ?
Yes

Workaround:
Instead of defining jna.library.path, set library.custom
-Dlibrary.custom=lib\custom.dll
This tricks LibraryExtractor.getLibraryPath()

Stack trace of the Exception:
ERROR: Failed to extract library mOcrApi
java.io.IOException: Cannot list contents of bundle://5.0:1/libraries/win32
at com.ochafik.net.URLUtils.listFiles(URLUtils.java:58)
at com.ochafik.lang.jnaerator.runtime.LibraryExtractor.getLibraryPath(Li
braryExtractor.java:96)
at xx.CustomLibrary.(CustomLibrary.jav
a:18)
at xx.CustomDriver.(CustomDriver.java
:16)
at xx.CustomBundleActivator.start(CustomBundleActivator
eActivator.java:12)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAct
ion.java:633)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1822)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1739)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1143)

    at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264

)
at java.lang.Thread.run(Unknown Source)

Google Code Info:
Issue #: 76
Author: A.Kambu...@gmail.com
Created On: 2010-11-30T15:21:38.000Z
Closed On:

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions