Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manifest missing required imports for OSGi #136

Open
dkartaschew opened this issue Apr 16, 2019 · 0 comments
Open

Manifest missing required imports for OSGi #136

dkartaschew opened this issue Apr 16, 2019 · 0 comments

Comments

@dkartaschew
Copy link

dkartaschew commented Apr 16, 2019

When running in the Equinox OSGi environment (in our case as an Eclipse Plugin), attempting to using any of the POSIX functions results in only the JavaPOSIX being presented via the POSIXFactory.getPOSIX() method.

The following exception is noted on attempting to load one of the native POSIX implementations:

BundleLoader[com.github.jnr.posix_3.0.49].findClassInternal(jnr.ffi.provider.jffi.NativeClosureProxy)
BundleLoader[com.github.jnr.posix_3.0.49].findLocalClass(jnr.ffi.provider.jffi.NativeClosureProxy)
ModuleClassLoader[com.github.jnr.posix_3.0.49 - /opt/plugins/com.github.jnr.posix_3.0.49.jar].findClassImpl(jnr.ffi.provider.jffi.NativeClosureProxy)
ModuleClassLoader[com.github.jnr.posix_3.0.49].loadClass(jnr.ffi.provider.jffi.NativeClosureProxy) failed.
java.lang.ClassNotFoundException: jnr.ffi.provider.jffi.NativeClosureProxy cannot be found by com.github.jnr.posix_3.0.49
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:511)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:414)
	at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:153)

The root cause is missing required import packages in the manifest.

The manifest with jnr-posix 3.0.49 notes:

Import-Package: jnr.constants;version="[0.9,1)",
jnr.constants.platform;version="[0.9,1)",
jnr.constants.platform.windows;version="[0.9,1)",
jnr.ffi;version="[2.1,3)",
jnr.ffi.annotations;version="[2.1,3)",
jnr.ffi.byref;version="[2.1,3)",
jnr.ffi.mapper;version="[2.1,3)",
jnr.ffi.provider;version="[2.1,3)",
jnr.ffi.types;version="[2.1,3)"

Which is missing a number of packages that jnr-posix relies on. I suspect this is due to bnd (which the maven bundle plugin uses to create the bundle entries) is failing to recognise their usage due to the amount of reflection that jnr in general uses. (Something that is common with libraries that use lots of reflection or direct class loading).

One solution we've come up with is to replace the notation in the POM, with < Require-Bundle >{all dependencies} < /Require-Bundle > as a workaround. However, since Require-Bundle is discouraged in OSGi, I'm hesitant to share this.

The other solution is to define DynamicImport-Package: * in the manifest which with limited testing worked as well...

Another possible solution mentioned by another team member (in the office) was to create a jnr-osgi bundle that includes all JNR projects in a single bundle, that exports all packages?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant