Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 464926

Summary: java.awt.Headless exception when running with Java7
Product: [Tools] GEF Reporter: Alexander Nyßen <nyssen>
Component: GEF FXAssignee: Alexander Nyßen <nyssen>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3    
Version: unspecified   
Target Milestone: 3.10.0 (Mars) M7   
Hardware: PC   
OS: Mac OS X   
Whiteboard:

Description Alexander Nyßen CLA 2015-04-18 03:48:58 EDT
When running our MVC logo example with Java7, the following exception is thrown. Everything works fine when starting it with Java8.

Exception in runnable
java.awt.HeadlessException
	at java.awt.MouseInfo.getPointerInfo(MouseInfo.java:74)
	at org.eclipse.gef4.fx.nodes.FXUtils.getPointerLocation(FXUtils.java:150)
	at org.eclipse.gef4.mvc.fx.behaviors.FXHoverBehavior.registerMouseHandler(FXHoverBehavior.java:335)
	at org.eclipse.gef4.mvc.fx.behaviors.FXHoverBehavior.startHandleCreationDelay(FXHoverBehavior.java:362)
	at org.eclipse.gef4.mvc.fx.behaviors.FXHoverBehavior.onHover(FXHoverBehavior.java:250)
	at org.eclipse.gef4.mvc.fx.behaviors.FXHoverBehavior.onHoverChange(FXHoverBehavior.java:263)
	at org.eclipse.gef4.mvc.behaviors.HoverBehavior.propertyChange(HoverBehavior.java:84)
	at java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:335)
	at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:327)
	at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:263)
	at org.eclipse.gef4.mvc.models.HoverModel.setHover(HoverModel.java:84)
	at org.eclipse.gef4.mvc.fx.policies.FXHoverOnHoverPolicy.hover(FXHoverOnHoverPolicy.java:25)
	at org.eclipse.gef4.mvc.fx.tools.FXHoverTool$1.handle(FXHoverTool.java:92)
	at org.eclipse.gef4.mvc.fx.tools.FXHoverTool$1.handle(FXHoverTool.java:1)
	at com.sun.javafx.event.CompositeEventHandler.dispatchCapturingEvent(CompositeEventHandler.java:78)
	at com.sun.javafx.event.EventHandlerManager.dispatchCapturingEvent(EventHandlerManager.java:202)
	at com.sun.javafx.event.EventHandlerManager.dispatchCapturingEvent(EventHandlerManager.java:159)
	at com.sun.javafx.event.CompositeEventDispatcher.dispatchCapturingEvent(CompositeEventDispatcher.java:22)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:31)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
	at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
	at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:33)
	at javafx.event.Event.fireEvent(Event.java:171)
	at javafx.scene.Scene$MouseHandler.process(Scene.java:3311)
	at javafx.scene.Scene$MouseHandler.process(Scene.java:3151)
	at javafx.scene.Scene$MouseHandler.access$1900(Scene.java:3106)
	at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1563)
	at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2248)
	at com.sun.javafx.tk.quantum.EmbeddedScene$2$1.run(EmbeddedScene.java:194)
	at com.sun.javafx.tk.quantum.EmbeddedScene$2$1.run(EmbeddedScene.java:176)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sun.javafx.tk.quantum.EmbeddedScene$2.run(EmbeddedScene.java:176)
	at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
	at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
	at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
	at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
	at org.eclipse.swt.widgets.Display.applicationNextEventMatchingMask(Display.java:5024)
	at org.eclipse.swt.widgets.Display.applicationProc(Display.java:5405)
	at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method)
	at org.eclipse.swt.internal.cocoa.NSApplication.nextEventMatchingMask(NSApplication.java:94)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3666)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1112)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:993)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:654)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:598)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:138)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Comment 1 Alexander Nyßen CLA 2015-04-18 04:09:30 EDT
Interestingly, when starting an Eclipse (Mars M6) runtime with Java7, GraphicsEnvironment.isHeadless() returns true, while using Java8 it returns false.
Comment 2 Alexander Nyßen CLA 2015-04-18 04:21:46 EDT
(In reply to Alexander Nyßen from comment #1)
> Interestingly, when starting an Eclipse (Mars M6) runtime with Java7,
> GraphicsEnvironment.isHeadless() returns true, while using Java8 it returns
> false.

It seems that in case of Java7, the system property "java.awt.headless" is set to true, while in case of Java8 it is unset.
Comment 3 Alexander Nyßen CLA 2015-04-18 11:51:04 EDT
Adjusted FXUtils#getMouseLocation() to adjust the "awt.headless" property value before calling MouseInfo#getPointerInfo() in case it is set to "true". The value of "awt.headless" will be restored to the prior to calling FXUtils#getMouseLocation() in case it was set. 

Resolving as fixed in 3.10.0M7.