0

The application has a "current progress" screen consisting of a number of text boxes and tableviews. Incoming data is processed in a separate thread and stored in a database. When processing is finished, it toggles a SimpleBooleanProperty.

On the Java FX thread, I attach a change listener to the property. On change, I call an update routine that queries the database and updates the current progress screen.

Sometimes, the display just stops updating. My logs show the following exception:

30-08-18 09:04:15.781 ERROR java.lang.Throwable - Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
30-08-18 09:04:15.781 ERROR java.lang.Throwable -   at javafx.scene.Scene$ScenePulseListener.synchronizeSceneNodes(Scene.java:2289)
30-08-18 09:04:15.781 ERROR java.lang.Throwable -   at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2419)
30-08-18 09:04:15.782 ERROR java.lang.Throwable -   at com.sun.javafx.tk.Toolkit.lambda$runPulse$29(Toolkit.java:398)
30-08-18 09:04:15.782 ERROR java.lang.Throwable -   at java.security.AccessController.doPrivileged(Native Method)
30-08-18 09:04:15.782 ERROR java.lang.Throwable -   at com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:397)
30-08-18 09:04:15.782 ERROR java.lang.Throwable -   at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:424)
30-08-18 09:04:15.782 ERROR java.lang.Throwable -   at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:510)
30-08-18 09:04:15.782 ERROR java.lang.Throwable -   at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:490)
30-08-18 09:04:15.782 ERROR java.lang.Throwable -   at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$403(QuantumToolkit.java:319)
30-08-18 09:04:15.782 ERROR java.lang.Throwable -   at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
30-08-18 09:04:15.782 ERROR java.lang.Throwable -   at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
30-08-18 09:04:15.782 ERROR java.lang.Throwable -   at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
30-08-18 09:04:15.782 ERROR java.lang.Throwable -   at java.lang.Thread.run(Unknown Source)

There is no indicator here as to where in my program things have gone wrong. I've tried to duplicate the issue without success.

Anyone have any thoughts on what this could be or how to troubleshoot it?

EDIT: The "progess screen" shows incoming and outgoing network messages and queries a database to update several fields on the screen. In all the examples I've seen, the background thread is started from the JavaFX main thread, but in this case the background thread (a server) is started before the JavaFX thread. I want to trigger the update of the JavaFX thread on a message incoming to the server thread.

M. Teasdale
  • 323
  • 3
  • 17
  • If you're directly modifying the property from the background thread, all the listeners are invoked on the thread modifying the property. If one of the listeners modifies the GUI, the this may result in a exception during layout. – fabian Aug 30 '18 at 18:33
  • 1
    BTW: The solution would be using `Platform.runLater` or using a `Task` and doing the update form the `Task.onSucceeded` handler. – fabian Aug 30 '18 at 18:42
  • "*When processing is finished, it toggles a SimpleBooleanProperty.*" What is "it"? – user1803551 Aug 31 '18 at 13:07
  • @user1803551 "It" refers to the background thread. – M. Teasdale Sep 01 '18 at 23:35
  • @fabian, The property is being modified on the background thread, but the only listener is in an object on the JavaFX thread. The two threads share the same booleanProperty. – M. Teasdale Sep 01 '18 at 23:37
  • As fabian said, doesn't matter if you attached the listener on the JavaFX thread, whichever thread changes the property will host the resulting invocations. – user1803551 Sep 01 '18 at 23:51
  • Possible duplicate of [JavaFx: Update UI label asynchronously with messages while application different methods execution](https://stackoverflow.com/questions/19968012/javafx-update-ui-label-asynchronously-with-messages-while-application-different) – user1803551 Sep 01 '18 at 23:51

0 Answers0