java.lang.NoSuchMethodException: when exporting image

Found a bug? Post here.
Post Reply
ted
Posts: 57
Joined: Wed 25. Jul 2012, 22:53

java.lang.NoSuchMethodException: when exporting image

Post by ted » Tue 7. Aug 2012, 11:31

Using Apple.MacBookPro.OSX.SnowLeopard.Eclipse.Juno:
jreality 5494 [http:fs.math....]>->Replace With->Latest from repository
jreality>src-ui>de.jreality.ui.viewerapp>ViewerApp.java 5037>->Run As->1 Java Application
View->Show bean shell
[JRealityBeanShell]>self.setGeometry(Primitives.sphere(20))
File->Export->Image
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(Statement.java:260)
	at java.beans.Statement.access$000(Statement.java:39)
	at java.beans.Statement$2.run(Statement.java:140)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.beans.Statement.invoke(Statement.java:137)
	at java.beans.Expression.getValue(Expression.java:98)
	at de.jreality.ui.viewerapp.actions.file.ExportImage.actionPerformed(ExportImage.java:132)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028)
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
	at javax.swing.AbstractButton.doClick(AbstractButton.java:389)
	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:809)
	at com.apple.laf.AquaMenuItemUI.doClick(AquaMenuItemUI.java:137)
	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:850)
	at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
	at java.awt.Component.processMouseEvent(Component.java:6375)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
	at java.awt.Component.processEvent(Component.java:6140)
	at java.awt.Container.processEvent(Container.java:2083)
	at java.awt.Component.dispatchEventImpl(Component.java:4737)
	at java.awt.Container.dispatchEventImpl(Container.java:2141)
	at java.awt.Component.dispatchEvent(Component.java:4565)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4619)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4280)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4210)
	at java.awt.Container.dispatchEventImpl(Container.java:2127)
	at java.awt.Window.dispatchEventImpl(Window.java:2482)
	at java.awt.Component.dispatchEvent(Component.java:4565)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:684)
	at java.awt.EventQueue.access$000(EventQueue.java:85)
	at java.awt.EventQueue$1.run(EventQueue.java:643)
	at java.awt.EventQueue$1.run(EventQueue.java:641)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
	at java.awt.EventQueue$2.run(EventQueue.java:657)
	at java.awt.EventQueue$2.run(EventQueue.java:655)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:654)
	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)
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 ExportImage.java.

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();
		sv.setSceneRoot(Primitives.wireframeSphere());
		BufferedImage bi;
		bi = sv.renderOffscreen(1000, 1000);
		JFrame jf1 = new JFrame();
		jf1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		jf1.setVisible(true);
		jf1.getContentPane().add(new JLabel(new ImageIcon(bi)));
		jf1.pack();
	}
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.

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: java.lang.NoSuchMethodException: when exporting image

Post by gunn » Tue 7. Aug 2012, 20:43

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.
jReality core developer

ted
Posts: 57
Joined: Wed 25. Jul 2012, 22:53

Re: java.lang.NoSuchMethodException: when exporting image

Post by ted » Tue 7. Aug 2012, 21:47

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/ViewerApp.java
===================================================================
--- src-ui/de/jreality/ui/viewerapp/ViewerApp.java	(revision 5494)
+++ src-ui/de/jreality/ui/viewerapp/ViewerApp.java	(working copy)
@@ -48,6 +48,8 @@
 import java.beans.Beans;
 import java.beans.Expression;
 import java.beans.Statement;
+import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.lang.reflect.Constructor;
 import java.net.URL;
@@ -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!

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: java.lang.NoSuchMethodException: when exporting image

Post by gunn » Wed 8. Aug 2012, 14:02

Thanks, Ted. I've inserted the patch into ViewerApp.java and checked it into the repository.
jReality core developer

Post Reply