JPro-one / JPro-Tickets

The right place to report about bugs or suggest improvements for JPro.
https://www.jpro.one
9 stars 4 forks source link

Cannot run a quarkus-fx-based app with jpro #179

Open hallvard opened 1 month ago

hallvard commented 1 month ago

I'm trying out Quarkus as a platform for Java desktop apps. It has an extension named quarkus-fx, that allows the quarkus platform and javafx application to work together. However, in such an application the main application class must implement QuarkusApplication instead of subclassing of javafx' Application class, so cannot be started by jpro:

@QuarkusMain
public class WbApplication implements QuarkusApplication {

    @Override
    public int run(final String... args) {
        Application.launch(FxApplication.class, args);
        return 0;
    }

    public static void main(String[] args) {
        Quarkus.run(WbApplication.class, args); 
    }
}

It's the FxApplication (library) class that extends Application, not WbApplication.

Quarkus and quarkus-fx is an interesting platform, so perhaps jpro could support it?

FlorianKirmaier commented 1 month ago

Hi hallvard!

First, thank you for mentioning this issue. It's, of course, important for us to support all reasonable JavaFX environments.

In my first analysis, I noticed a more fundamental issue. There are solutions to work around the "Application" issue. However, the real issue is that Quarkus "reloads" all classes using a new Classloader. JavaFX is loaded twice. Quarkus uses it's reloaded JavaFX Classes. JPro uses the original JavaFX Classes. The solution would probably be to "replace" the current JPro Startup Mechanism, and move it into the Quarkus Classloader.

It probably sounds more complicated as it is.

FlorianKirmaier commented 1 month ago

@hallvard We just made a prototype working. It required some changes in JPro itself. We have to clean it up. Then, we can make it available as a sample We can probably give you something at the beginning of next week.

hallvard commented 1 month ago

Wow, that was quick! Looking forward to testing it!

Btw, here's the app I wanted to try out: https://github.com/hallvard/wb-fx

FlorianKirmaier commented 1 month ago

Small minimal "Quarkus JPro Helloworld": https://github.com/FlorianKirmaier/jpro-quarkus

But there are currently quite some issues. Quarkus does a LOT of Classloader and deployment magic. It also has it's own dependency resolver. In this version, only running works, deployment doesn't work now.

It also only works with the special JPro Version used in this example.

It is also worth noting that you have to change the JavaFX version in the pom to the one JPro uses.

21.0.3-jpro Quarkus seems to ignore the classpath JPro provides, so it only accepts it, when its written in the pom.
FlorianKirmaier commented 1 month ago
Screenshot 2024-07-17 at 21 48 54

I quickly tested your application. Seems to work.