<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi everyone<div><br></div><div>as explained in this other post (<a href="http://www.vtk.org/pipermail/vtkusers/2010-October/112895.html">http://www.vtk.org/pipermail/vtkusers/2010-October/112895.html</a>) and in my article (<a href="http://dev.artenum.com/blog/ben/posts/osgi_vtk_and_macosx">http://dev.artenum.com/blog/ben/posts/osgi_vtk_and_macosx</a>), I have embedded VTK dynamic libraries inside an OSGi bundle.</div><div><br></div><div>I have the same error message than Jérémie who did not embed the libraries in the JAR bundle file but passed the DYLD_LIBRARY_PATH to the external libraries directory.</div><div><br></div><div>However, since I used the -Xcheck:jni option, I have a more verbose error:</div><div><br></div><div>WARNING in&nbsp;native&nbsp;method: JNI call made with exception pending<div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at vtk.vtkPanel.RenderCreate(Native Method)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at vtk.vtkPanel.Render(vtkPanel.java:166)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>- locked &lt;1060ffa88&gt; (a vtk.vtkPanel)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at vtk.vtkPanel.paint(vtkPanel.java:189)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at sun.awt.RepaintArea.paintComponent(RepaintArea.java:276)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at sun.awt.RepaintArea.paint(RepaintArea.java:241)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at apple.awt.ComponentModel.handleEvent(ComponentModel.java:263)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at java.awt.Component.dispatchEventImpl(Component.java:4790)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at java.awt.Component.dispatchEvent(Component.java:4544)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at java.awt.EventQueue.dispatchEvent(EventQueue.java:635)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)</div><div>FATAL ERROR in&nbsp;native&nbsp;method: Bad global or local ref passed to JNI</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at vtk.vtkPanel.RenderCreate(Native Method)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at vtk.vtkPanel.Render(vtkPanel.java:166)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>- locked &lt;1060ffa88&gt; (a vtk.vtkPanel)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at vtk.vtkPanel.paint(vtkPanel.java:189)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at sun.awt.RepaintArea.paintComponent(RepaintArea.java:276)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at sun.awt.RepaintArea.paint(RepaintArea.java:241)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at apple.awt.ComponentModel.handleEvent(ComponentModel.java:263)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at java.awt.Component.dispatchEventImpl(Component.java:4790)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at java.awt.Component.dispatchEvent(Component.java:4544)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at java.awt.EventQueue.dispatchEvent(EventQueue.java:635)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)</div><div>Invalid memory access of location 0x0 rip=0x1010af1f4</div><div>./ben.sh: line 11: 23453 Abort trap &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;java -Xcheck:jni -jar org.eclipse.osgi_3.6.0.v20100517.jar -console</div></div><div><br></div><div>This is not a ClassLoader issue. In OSGi, each bundle has its own classloader. My VTK bundle both loads the vtk.jar and the native libraries and should thus use the same classloader to perform both.</div><div><br></div><div>To be sure about it, I added in the&nbsp;vtkNativeLibrary.java class a new method, called&nbsp;LoadAllNativeLibrariesForOSGi(), that performs all the System.loadLibrary calls that I previously did in my OSGi BundleActivator (this way, it is executed in the same ClassLoader that the one that loaded vtk.jar). I re-compiled VTK and ended with the same error message.</div><div><br></div><div>Do you have any idea what could cause this problem?</div><div>I read here&nbsp;<a href="http://www.vtk.org/pipermail/vtkusers/2007-February/089476.html">http://www.vtk.org/pipermail/vtkusers/2007-February/089476.html</a>&nbsp;that it could come from a compatibility issue with OSX Cocoa. The solution suggested there was to compile using Carbon instead of Cocoa. But:</div><div>- this is not a satisfactory solution, as Carbon is less and less supported by Apple</div><div>- it is not possible on the latest versions of MacOSX, as Java is 64bits only and Carbon cannot be compiled in 64bits</div><div><br></div><div>Any suggestion? :-)</div><div><br></div><div>Kind regards,</div><div><br></div><div>Benoît</div><div><div></div></div><div><div><br></div><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(0, 0, 0, 1);"><b>De : </b></span><span style="font-family:'Helvetica'; font-size:medium;">Gerrick Bivins &lt;<a href="mailto:gbivins@objectreservoir.com">gbivins@objectreservoir.com</a>&gt;<br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(0, 0, 0, 1);"><b>Date : </b></span><span style="font-family:'Helvetica'; font-size:medium;">11 octobre 2010 17:31:40 HAEC<br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(0, 0, 0, 1);"><b>À : </b></span><span style="font-family:'Helvetica'; font-size:medium;">Jérémie Turbet &lt;<a href="mailto:jet@artenum.com">jet@artenum.com</a>&gt;<br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(0, 0, 0, 1);"><b>Cc : </b></span><span style="font-family:'Helvetica'; font-size:medium;"><a href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(0, 0, 0, 1);"><b>Objet : </b></span><span style="font-family:'Helvetica'; font-size:medium;"><b>Rép : [vtkusers] VTK + OSGi &amp; RenderCreate native method</b><br></span></div><br>Hi,<div>I haven't done osgi specifically, but have created a netbeans platform module (similar concept, see this link&nbsp;<a href="http://wiki.netbeans.org/OSGiAndNetBeans#NetBeans_and_OSGi">http://wiki.netbeans.org/OSGiAndNetBeans#NetBeans_and_OSGi</a>) that wraps vtk.&nbsp;</div>

<div><br></div><div>I ended up forcing the load of the required libs for my app when the module loads via the module installer (not sure what the equivalent is in osgi terms,bundle activator maybe?) similar to the technique described here for loading jogl in a netbeans application:</div>

<div><a href="http://forums.netbeans.org/viewtopic.php?t=16272">http://forums.netbeans.org/viewtopic.php?t=16272</a></div><div><br></div><div>I had issues on mac where it wouldn't load the libraries unless I specified the&nbsp;<span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 12.5px; border-collapse: collapse; "></span></div>

<div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 12.5px; border-collapse: collapse; ">arch type of the libs matched that of the jvm. Also, had some weirdness with the suffixes of the libs (jnilib vs dylib see :</span><a href="http://forums.netbeans.org/ntopic16681.html">http://forums.netbeans.org/ntopic16681.html</a><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 12.5px; border-collapse: collapse; ">)&nbsp;</span></div>

<div><br></div><div>On windows or linux, things worked as expected (ie how it was described in the docs) so you may want to try your module on one of those platforms before trying on OSX.</div><div><br></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 12.5px; border-collapse: collapse; "></span>biv</div>

<div><br></div><div><br></div><div><br></div><div><br><div class="gmail_quote">On Mon, Oct 11, 2010 at 7:29 AM, Jérémie Turbet <span dir="ltr">&lt;<a href="mailto:jet@artenum.com">jet@artenum.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div style="word-wrap:break-word"><span style="white-space:pre-wrap">        </span>Hi all,<div><br></div><div>Before my question, a small description of the context:&nbsp;</div>

<div>&nbsp;&nbsp;I'm trying to create an OSGi bundle displaying some VTK stuff using Java wrapping.</div><div>&nbsp;&nbsp;The service class is a simple POJO (OSGi classes and configuration are managed using iPOJO). when I test it out of OSGi environment, it works well, load libraries, and displays a beautiful 3D cone in a window. When I ask to the OSGi container to launch my service, libraries are loaded, objects are instantiated, but as soon as I ask a rendering (using vtkPanel::Render() ) I get this error "Invalid memory access of location 0x0 rip=0x10109cdcc" which looks like a null pointer exception...</div>

<div>&nbsp;&nbsp;</div><div>&nbsp;&nbsp;For a debugging purpose, I have made a copy/paste of vtkPanel class into MyVtkPanel (which is in my application package) and replace the vtkPanel by MyVtkPanel into my small test application. I expected no change in the resulting behaviour, instead I have an unsatisfied link error on RenderCreate() method.</div>

<div>This method is declared as native, but my DYLD_LIBRARY_PATH points to the VTK libs. I thought it should have found this method....</div><div><br></div><div>Does someone has an idea of why this error occurs, is there some access restriction due to the class location (which is the only change... I guess...) ?</div>

<div><br></div><div>to summarise:</div><div>vtkPanel panel = new vtkPanel()</div><div>panel.Render()</div><div>works fine</div><div>&nbsp;</div><div><div>vtkPanel panel = new vtkPanel()</div><div>panel.Render()</div><div>leads to "<span style="color:rgb(222, 42, 0);font-family:Monaco;font-size:11px">Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: test.vtk.impl.MyVtkPanel.RenderCreate(Lvtk/vtkRenderWindow;)I</span></div>

<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;color:rgb(222, 42, 0)"><span style="white-space:pre-wrap">        </span>at test.vtk.impl.MyVtkPanel.RenderCreate(<span style="text-decoration:underline;color:#121f8f">Native Method</span>)<span style="color:rgb(0, 0, 0);font-family:Helvetica;font-size:medium">"</span></div>

</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;color:rgb(222, 42, 0)"><span style="color:rgb(0, 0, 0);font-family:Helvetica;font-size:medium"><br></span></div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;color:rgb(222, 42, 0)">

<span style="color:rgb(0, 0, 0);font-family:Helvetica;font-size:medium"><br></span></div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;color:rgb(222, 42, 0)"><span style="color:rgb(0, 0, 0);font-family:Helvetica;font-size:medium"><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">

<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">&gt;nm libvtkRenderingJava.dylib &nbsp;| grep RenderCreate</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">0000000000047b9b T _Java_vtk_vtkPanel_RenderCreate</div>

<div><br></div><div>Tested under Mac OSX snow leopard with VTK 5.40, 5.6.0 and 5.6.1</div><div><br></div><div><span style="white-space:pre-wrap">        </span>Regards,</div><div><br></div><div><span style="white-space:pre-wrap">                </span>JeT</div>

<div><br></div><div>PS: if someone has some experience with VTK + OSGi, some tips would be of great help. I'm a little bit stuck with it...</div></div></span></div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;color:rgb(222, 42, 0)">

</div></div><br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com/" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div>
_______________________________________________<br>Powered by <a href="http://www.kitware.com/">www.kitware.com</a><br><br>Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br><br>Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><br><br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br></blockquote></div><br></div></blockquote></div><br>
<br></body></html>