-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support spring-boot package? #96
Comments
What doesn't it support? Doesn't the spring boot app expose an Application class you can point to? |
Hi. I´m trying to run my JavaFX-Spring Boot application using the fxlauncher, too. There are several challanges to get it running:
The current issue: The fxlauncher can currently not handle this because it expects an javafx.application.Application type. Error creating app class
|
I have just tried the following and the application is able to start! Add spring-boot-loader dependency to FXLauncher project:
Change "Laucher.java" `private final AbstractLauncher superLauncher = new AbstractLauncher() {
=> It would be great if a similar implementation could be provided in a separate class, like SpringBootLauncher.java?! |
We have the headless launcher which should work with this approach :) |
great thank you. It works perfectly ;) For others: |
Glad to hear it :)) |
One more comment to this topic: The headless launcher works in principle fine, but it would be nicer if the FXLauncher UI / the update progress bar could be visible. I guess therefore a new Launcher implementation would be necessary. Furthermore for some reason some resources (i.E. css files) are not found. If i start the executable jar directly everything is fine, if i am using java -jar fxlauncher the application starts but resources are not found. I have currently no idea why, but maybe its related to the classloader?!
https://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html |
I think it would be quite easy to make
Method mainMethod = appClass.getMethod("main", String[].class);
mainMethod.invoke(null, (Object) new String[0]); (Or additionally pass parameters) It would probably be best to split this function into two new functions: I think it's as easy as that - do you want to try and submit a PR? About the resources not being found: We actually do call |
Hey, thanks for your hint. I have implemented it, but currently i am receiving an IllegalStateException: "Application launch must not be called more than once"
It looks like that the main() method of the Spring Boot JarLauncher is invoked correctly and tries to start my JavaFX Application main Method. The message "Application launch must not be called more than once" is very confusing, but i will spend some time to analyse that problem later... And regarding the stylesheet problem. There is no special implementation for that. The errors are coming from the Java com.sun.javafx.css.StyleManager class. (method. loadStylesheetUnPrivileged()) The css files are available within the Jars, i´ve verified it. If i am starting the executable jar without the fxlauncher, the stylesheets are correctly loaded. |
The IllegalStateException: "Application launch must not be called more than once" occurs in the JavaFX main class when "launch()" from com.sun.javafx.application.LauncherImpl the is called. This method is previously called by the FXLauncher main method, too... But unfortunetly i have currently no idea how to solve it. |
JavaFX only allows you to run launch() once per JVM, so I guess you have to manually start your app from a JavaFX app class that just forwards the correct calls. Should be doable. |
I´m wondering why the approach with the "SpringBootLauncher" has worked.... What do you mean with "manually start your app from a JavaFX app?" Implementing another JavaFx App which executes "exec("java -jar MyApp.jar"); ? |
Do you mean why the headless launcher worked? That's because it didn't start a JavaFX Application to show the progress ui, hence you are free to do so later. What I mean you should do, is to implement |
(I thought that my previous solution worked as well / integrating spring loader dependency and invoke the JarLauncher directly... ) I´ve implemented several solutions... Each has it own problems. So, the best solution for me (for now) is using the JFXPanel together with Swing to avoid any "Application launch must not be called more than once" problems. https://github.com/humpfle/fxlauncher/commit/8c8dfa2c3dfa3e20090bb709490cf0ac98dfba60 |
I think this is based on a misunderstanding somewhere, this shouldn't be necessary, but unfortunately I don't have the time to look into it at the moment. I can merge if you supply a PR as it wouldn't hurt anything though :) |
I am going to do some more testing. But it would be nice if you can merge it then. (What is a PR :) ?) |
PR is a Pull Request: https://help.github.com/articles/about-pull-requests/ |
Ok, great. Im familiar with the term "Merge Request" but it seems to be the same. So I will supply a Pull Request in the next few days. 👍 |
Fantastic :) |
There are still other issues related to spring boot. Spring boot has its own classloader (LaunchedURLClassLoader). I am not able to get it fully worked with the fxlauncher. If i use the HeadlessLauncher, some resources are not found and some reflection logic is not working. If i´m using the SwingJFXLauncher, i got class not found exceptions.. Since with Spring boot, we have only one fat executable JAR and no other dependencies (so the app.xml contains only one entry as well), maybe it would be really better just to use the ProgressBuilder to start the jar in a new application. |
Thanks for the info. If that works, then I say go for it. I've never used/needed SpringBoot myself, since I write my desktop apps in TornadoFX, but it's good to have a more or less working solution for SpringBoot as well. |
Finally it works and it will work for any other executable jar as well. Please have a look here: (Note that i´ve also deleted the previous Swing JFXPanel approach): |
Very good work, that was exactly what I was hoping for :) |
great! can you please build a new release? |
Absolutely, will release tonight! |
FXLauncher 1.0.18 is in Maven Central :) |
It seems that something went wrong. The changes are not present in 1.0.18. Can you please verify it? Thanks! |
That's weird, I did compile with this fix. I'll do a new release next week with another fix, will make sure it's in there then. |
My javaFX APP is developed using spring-boot, and the project package uses spring-boot-maven-plugin, and fxlauncher doesn't seem to support this way.
The text was updated successfully, but these errors were encountered: