Re: JOGL with OSGi
Posted by
Wade Walker on
May 09, 2013; 1:37pm
URL: https://forum.jogamp.org/JOGL-with-OSGi-tp3773888p4029131.html
Recently, I successfully used JOGL's native library JARs in an Eclipse RCP project, with the help of a new fix to JarUtil. I'm not sure if it will work in Karaf the same way, but it might.
First, you add the JOGL native library JAR files (e.g. gluegen-rt-natives-linux-amd64.jar and jogl-all-natives-linux-amd64.jar if you're in 64-bit Linux) into an OSGi bundle somehow. In an Eclipse project, this means adding them to a plugin, but in Karaf it may work differently. You can add the JARs for all 5 platforms if you want, or just for the platform you're running on.
Then you add this code to your project so it runs before JOGL is invoked:
JarUtil.setResolver( new JarUtil.Resolver() {
public URL resolve( URL url ) {
try {
System.out.print( "before resolution: " + url.toString() );
return( FileLocator.resolve( url ) );
} catch( IOException ioexception ) {
return( url );
}
}
} );
FileLocator is an Eclipse class from org.eclipse.core.runtime, there may be something similar in Karaf. It converts OSGi "bundleresource:" URLs into "file:" URLs that JOGL can use internally to unpack its .so/.dll/.jnilib files (more details at
https://jogamp.org/bugzilla/show_bug.cgi?id=687). To debug this, you can just return the unresolved URL above and look at what's printed -- if they are bundleresource: or some other type of URL than file:, they need to be resolved somehow or JOGL can't find them.