Deadlock in Java/JavaFX: Application hangs because of a deadlock when loading plugins
posted 5 years ago
I am currently working on a desktop application developed in Java (core) and JavaFX (GUI) that requires loading plugins from independent JAR files, which are also developed in Java/JavaFX, dinamically.
The main project defines a GUI where the user can choose what plugin he wants to run. The process of loading that plugin works as follows:
1st. The User selects the plugin throughout the main application GUI.
2nd.The GUI processes the request and sends it to the Java Core.
3rd. The Java Core launches a new thread (so that the GUI does not freeze, by working asynchronously)
4th. Then the JAR is loaded in that thread and then it's executed
Here comes the point: We need the plugin to draw some JavaFX nodes in a certain area (a Panel previously defined for that purpose in the GUI), that's to say, we need to embed the plugin GUI into the main GUI in order to have ONLY ONE stage. This is important, we do not want to substitute one stage with another, but really EMBED one into the main one.
We have managed to represent some nodes in the main GUI such as labels or buttons, but the application hangs randomly due to a deadlock. The stacktrace generated by that deadlock is the following:
Is there any way to solve this problem?
Thanks in advance.