Page 1 of 1

java.lang.NoSuchMethodException: when exporting image

Posted: Tue 7. Aug 2012, 11:31
by ted
Using Apple.MacBookPro.OSX.SnowLeopard.Eclipse.Juno:
jreality 5494 [http:fs.math....]>->Replace With->Latest from repository
jreality>src-ui>de.jreality.ui.viewerapp> 5037>->Run As->1 Java Application
View->Show bean shell
Save as: junk123.png

throws exception with this output:

Code: Select all

Possibly no jogl libraries in java.library.path!
scene root is root
java.lang.NoSuchMethodException: <unbound>=SoftViewer.renderOffscreen(Integer, Integer, Double);
	at java.beans.Statement.invokeInternal(
	at java.beans.Statement.access$000(
	at java.beans.Statement$
	at Method)
	at java.beans.Statement.invoke(
	at java.beans.Expression.getValue(
	at de.jreality.ui.viewerapp.actions.file.ExportImage.actionPerformed(
	at javax.swing.AbstractButton.fireActionPerformed(
	at javax.swing.AbstractButton$Handler.actionPerformed(
	at javax.swing.DefaultButtonModel.fireActionPerformed(
	at javax.swing.DefaultButtonModel.setPressed(
	at javax.swing.AbstractButton.doClick(
	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(
	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(
	at java.awt.AWTEventMulticaster.mouseReleased(
	at java.awt.Component.processMouseEvent(
	at javax.swing.JComponent.processMouseEvent(
	at java.awt.Component.processEvent(
	at java.awt.Container.processEvent(
	at java.awt.Component.dispatchEventImpl(
	at java.awt.Container.dispatchEventImpl(
	at java.awt.Component.dispatchEvent(
	at java.awt.LightweightDispatcher.retargetMouseEvent(
	at java.awt.LightweightDispatcher.processMouseEvent(
	at java.awt.LightweightDispatcher.dispatchEvent(
	at java.awt.Container.dispatchEventImpl(
	at java.awt.Window.dispatchEventImpl(
	at java.awt.Component.dispatchEvent(
	at java.awt.EventQueue.dispatchEventImpl(
	at java.awt.EventQueue.access$000(
	at java.awt.EventQueue$
	at java.awt.EventQueue$
	at Method)
	at java.awt.EventQueue$
	at java.awt.EventQueue$
	at Method)
	at java.awt.EventQueue.dispatchEvent(
	at java.awt.EventDispatchThread.pumpOneEventForFilters(
	at java.awt.EventDispatchThread.pumpEventsForFilter(
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(
	at java.awt.EventDispatchThread.pumpEvents(
	at java.awt.EventDispatchThread.pumpEvents(
Wrote file /Users/ted/junk123.png
Junk123.png exists, but it is all black

I didn't check to see if adding lights, etc. would make it show up, but it seems the exception at least ought to be caught even if that's the case.

I tried stepping through the code and not sure why it thinks renderOffscreen isn't a method. It's in the SoftViewer class, and I can call it from my own code like this but get a gray image: Maybe someone more familiar with the code can take a look at

As I said, the ViewerApp generates a black image.

Here's a short snippet of code that generates a gray image that I made trying to isolate the problem...

Code: Select all

	public static void main(String[]unused) {
		SoftViewer sv = new SoftViewer();
		BufferedImage bi;
		bi = sv.renderOffscreen(1000, 1000);
		JFrame jf1 = new JFrame();
		jf1.getContentPane().add(new JLabel(new ImageIcon(bi)));
This code doesn't throw any exceptions, but it generates a plain gray image (maybe transparent) with nothing on it though the blue sphere shows up on the JReality Viewer window. Perhaps I'm missing something. Nevertheless, the ExportImage seems broken in the latest from the repository as of tonight.

Re: java.lang.NoSuchMethodException: when exporting image

Posted: Tue 7. Aug 2012, 20:43
by gunn
The message "Possibly no jogl libraries in java.library.path!" usually means you don't have the JOGL backend active, and hence are using the software backend, which doesn't support off-screen rendering.

The problem is that the jogl.jar file is being loaded but the necessary native libraries are not being found. I believe you can indicate the location in Eclipse when examining the properties of jogl.jar (in the build path->libraries panel). You need to set this to point to the native libraries appropriate for your environment. The native libraries for JOGL are distributed with jReality under the jni folder.

Re: java.lang.NoSuchMethodException: when exporting image

Posted: Tue 7. Aug 2012, 21:47
by ted
OK I'll try that. Maybe the fix is to catch the exception and print out a message to that effect. Thanks.


Looking at first glance there's a README file. It might be appropriate to just pop up a dialog that reads the README and displays it on exception - or just dump it to System.err where the short message is currently being printed. Here's a patch that does that...

Code: Select all

Index: src-ui/de/jreality/ui/viewerapp/
--- src-ui/de/jreality/ui/viewerapp/	(revision 5494)
+++ src-ui/de/jreality/ui/viewerapp/	(working copy)
@@ -48,6 +48,8 @@
 import java.beans.Beans;
 import java.beans.Expression;
 import java.beans.Statement;
 import java.lang.reflect.Constructor;
@@ -55,6 +57,7 @@
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Scanner;
 import javax.swing.BorderFactory;
 import javax.swing.JFrame;
@@ -566,7 +569,11 @@
 						System.out.println("Possibly no jogl in classpath!");
 					} catch (UnsatisfiedLinkError le) {
 						System.out.println("Possibly no jogl libraries in java.library.path!");
-					}
+						try {
+							System.err.println("###\n"+new Scanner(new File("jni/README")).findWithinHorizon("(?s).*",0)+"\n###"); 					
+						} catch (FileNotFoundException e) {
+							System.err.println("see .../jreality/jni/README");
+						}					}
 				viewers = viewerList.toArray(new Viewer[viewerList.size()]);

Tested and working!

Re: java.lang.NoSuchMethodException: when exporting image

Posted: Wed 8. Aug 2012, 14:02
by gunn
Thanks, Ted. I've inserted the patch into and checked it into the repository.