Home > Back-end >  How to show Stacktrace of java.util.concurrent.CompletionException (Using JavaFX)
How to show Stacktrace of java.util.concurrent.CompletionException (Using JavaFX)

Time:12-17

I am developing a Java Library that is used in a Java GUI that is based on JavaFX. During manual testing, I can produce the following Error, printed to the console - the GUI hangs, but the window stays open:

java.util.concurrent.CompletionException: java.lang.IllegalStateException: Cannot load xxx.xxx.xxx.main.tab.editor.workspace.canvas.canvas

No Stacktrace, no line number, no class that caused the exception, nothing that I can work with.

How do I get a stacktrace for this?

I tried the following things already:

  • Instead of running the packaged jar with java -jar Application.jar, I tried just running the main class with mvn exec:java -Dexec.mainClass="xxx.xxx.xxx.App"
  • I tried using the verbose flag: java -verbose -jar Application.jar
  • From other threads, I tried the -XX:-OmitStackTraceInFastThrow flag

Nothing changed the error message to be anything else than this single line.

Edit: The exception is not caught in the project's own code, however it might be caught by a library - so I hope maybe this is something done by JavaFX itself and there is a way to fix it? I guess JavaFX should be the main source of concurrency in the project.

CodePudding user response:

I found the culprit, it is indeed the something JavaFX-y catching the error:

The class from the exception is a JavaFX...module (? component? whatever, it has a CanvasView and CanvasPresenter class and is in a folder that contains all the ressources like .fxml and .properties files, and it is really hard to google the basic concept)

The exception is thrown in the CanvasPresenter initialize method (CanvasPresenter implements the Initializable interface), and there I could wrap the offending code in a try {...} catch(Exception e) {e.printStackTrace();} and get more information.

  • Related