Problem with OSGi Bundle: sun.nio.ch.DirectBuffer

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with OSGi Bundle: sun.nio.ch.DirectBuffer

Justin
I'm trying to wrap the JOGL libraries into an OSGi bundle using Eclipse. I can get the plugin to work from within Eclipse using its Equinox container, but problems arise when I export the plugin and try to use it from Apache Felix, for example.

The error I get when running my bundle outside Eclipse:

java.lang.NoClassDefFoundError: sun/nio/ch/DirectBuffer
        at com.jogamp.common.jvm.JVMUtil.initialize(Native Method)
        at com.jogamp.common.jvm.JVMUtil.<clinit>(JVMUtil.java:59)
        at javax.media.opengl.GLProfile.<clinit>(GLProfile.java:1141)

I believe this has to do with Eclipse loading certain packages (including javax.swing among others) that a pure OSGi bundle won't be aware of when deployed. I tried to manually add this package to the imported packages in my JOGL bundle manifest (works for javax.swing, which is needed by GLJPanel for instance), but Eclipse won't allow it with the sun.nio.ch package.

This is using JOGL2-rc2 (jogl-2.0-b23-20110303). I am using Mac OS X 10.6.

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Problem with OSGi Bundle: sun.nio.ch.DirectBuffer

Justin
I also came across this: http://java.sun.com/products/jdk/faq/faq-sun-packages.html

I suppose that explains why Eclipse won't let me export the sun.* packages, but it doesn't help me solve my problem.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with OSGi Bundle: sun.nio.ch.DirectBuffer

Justin
Surprisingly, I managed to figure this out soon after. In case anyone has a similar issue in the future, I found a nice post here:
http://blog.springsource.com/2009/01/19/exposing-the-boot-classpath-in-osgi/

For me, setting

proprety org.osgi.framework.bootdelegation=sun.*,com.sun.*

worked and was the most simple.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with OSGi Bundle: sun.nio.ch.DirectBuffer

gouessej
Administrator
I have never had this problem, I fill the fields Bundle-ClassPath and Export-Package for the JOGL bundle and Require-Bundle for the bundle that uses it.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Problem with OSGi Bundle: sun.nio.ch.DirectBuffer

Wade Walker
Administrator
In reply to this post by Justin
Interesting -- I've never tried to use a sun.* or com.sun.* class in an OSGI bundle, and I didn't realize it wouldn't work without special help. Thanks for posting this info!