Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » VTK and Equinox on Mac OS X(Strange JNI error not present with pure Java application)
VTK and Equinox on Mac OS X [message #636976] Wed, 03 November 2010 15:57 Go to next message
Benoît Thiébault is currently offline Benoît ThiébaultFriend
Messages: 11
Registered: October 2010
Junior Member
Hi everyone,

After a few tests with simple JNI examples ( http://www.eclipse.org/forums/index.php?t=msg&th=198290& amp;start=0&S=6ec8f34b252ceb8b5eab1380a39b0f00), I have tried to create an OSGi bundle with VTK (http://www.vtk.org), the open source Visualization ToolKit written in C++.

While it works like a charm on Linux, I have had much more troubles on OS X, that I detail here: http://dev.artenum.com/blog/ben/posts/osgi_vtk_and_macosx

The short story is that I had to:
- modify the dynamic libraries extensions from .dylib to .jnlib
- prepend an @loader_path prefix in the libraries transitive dependencies
- remove the version numbers from the library file names

I now have an OSGi bundle containing the Java classes together with the native libraries.

However, when I execute it with Equinox, I have an error raised by a native lib call (that crashes when calling the GetDrawingSurfaceInfo method in jawt.h):
WARNING in native method: JNI call made with exception pending
	at vtk.vtkPanel.RenderCreate(Native Method)
	at vtk.vtkPanel.Render(vtkPanel.java:166)
	- locked <1060ffa88> (a vtk.vtkPanel)
	at vtk.vtkPanel.paint(vtkPanel.java:189)
	at sun.awt.RepaintArea.paintComponent(RepaintArea.java:276)
	at sun.awt.RepaintArea.paint(RepaintArea.java:241)
	at apple.awt.ComponentModel.handleEvent(ComponentModel.java:263)
	at java.awt.Component.dispatchEventImpl(Component.java:4790)
	at java.awt.Component.dispatchEvent(Component.java:4544)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:635)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
FATAL ERROR in native method: Bad global or local ref passed to JNI
	at vtk.vtkPanel.RenderCreate(Native Method)
	at vtk.vtkPanel.Render(vtkPanel.java:166)
	- locked <1060ffa88> (a vtk.vtkPanel)
	at vtk.vtkPanel.paint(vtkPanel.java:189)
	at sun.awt.RepaintArea.paintComponent(RepaintArea.java:276)
	at sun.awt.RepaintArea.paint(RepaintArea.java:241)
	at apple.awt.ComponentModel.handleEvent(ComponentModel.java:263)
	at java.awt.Component.dispatchEventImpl(Component.java:4790)
	at java.awt.Component.dispatchEvent(Component.java:4544)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:635)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Invalid memory access of location 0x0 rip=0x1010af1f4
./ben.sh: line 11: 23453 Abort trap              java -Xcheck:jni -jar org.eclipse.osgi_3.6.0.v20100517.jar -console


I know I am not on VTK mailing list here Smile but I wonder why the exact same code works when I use a plain old Java application (with a main method) and why it crashes when bundled in OSGi ?

What does Equinox do that in particular could lead to such problem ?

Kind regards,

Benoît
Re: VTK and Equinox on Mac OS X [message #637273 is a reply to message #636976] Thu, 04 November 2010 19:21 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
Registered: July 2009
Senior Member
Richard Hall from Felix informed me that you had a similar issue in Felix. It seemed that the native library you have has a side effect that causes some classes to be loaded from the boot classpath but the OSGi class loader does not automatically grant the bundle class loader access to all packages from the boot class path. Specifying org.osgi.framework.bootdelegation=* should help you.

Is that true?

Tom.
Re: VTK and Equinox on Mac OS X [message #637278 is a reply to message #637273] Thu, 04 November 2010 19:44 Go to previous messageGo to next message
Benoît Thiébault is currently offline Benoît ThiébaultFriend
Messages: 11
Registered: October 2010
Junior Member
Yes, indeed: http://www.mail-archive.com/users@felix.apache.org/msg08866. html

With Felix moreover I had another issue: in the Bundle-NativeCode tag, the processor field is mandatory in Felix, not in Equinox, so I had to set it in my Manifest.

For the VTK problem also mentioned in this forum thread, I added "org.osgi.framework.bootdelegation=apple.*" in Felix configuration and it worked.

I tried it with Equinox but it did not work and I still get the same error.
This boot delegation variable has to be written in the config.ini file, isn't it?
Re: VTK and Equinox on Mac OS X [message #637281 is a reply to message #637278] Thu, 04 November 2010 20:04 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
Registered: July 2009
Senior Member
I opened bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=329480 about the Bundle-NativeCode discrepancy. I think processor should be a required attribute on Bundle-NativeCode.

For bootdelegation, it depends on how you are launching the framework. I assume you are launching it by running java -jar org.eclipse.osgi.jar

In that case file configuration/config.ini located in the current working directory should be read and use. Just to be sure, try specifying the setting as a java system property:

java -Dorg.osgi.framework.bootdelegation=apple.* -jar ...

Re: VTK and Equinox on Mac OS X [message #637282 is a reply to message #637281] Thu, 04 November 2010 20:07 Go to previous message
Benoît Thiébault is currently offline Benoît ThiébaultFriend
Messages: 11
Registered: October 2010
Junior Member
Ooops, my mistake, I misplaced the config.ini file in the same folder than Equinox and not in the configuration directory.

I corrected this mistake and it works perfectly!

An alternative solution proposed by Richard is to add apple.awt in the Import-Package tag and add org.osgi.framework.system.packages.extra=apple.awt in the config.ini file. I don't know what is the best of the two approaches...
Previous Topic:PackageAdmin.refreshPackages() - bundle graph calculation when fragment bundles are installed
Next Topic:EventAdmin best practices
Goto Forum:
  


Current Time: Tue Apr 23 05:28:50 GMT 2024

Powered by FUDForum. Page generated in 0.02994 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top