• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Bean not found in multi-module SpringBoot/JavaFX project

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When a WebClient is located in a separate module, SpringBoot cannot find the bean dependency.  Moving the client into the same module allows everything to work.

Looks like I cannot attach the very small sample project  Here it is shared on my OneDrive.  I can provide it in other ways if needed.

https://1drv.ms/u/s!AmzGF2MJK5rSdGHqazoLhA00YqE?e=mSjj93

Unmodified, the project should reproduce the missing bean error. Open the AnalysisController and switch to the WebClientStockClientLocal property and associated constructor to eliminate the missing bean problem.  

The project is using Java21, JavaFX21, groovy, and gradle.  The project also uses DI for the ViewManager and ViewModel just fine.   I am using the latest Intellij for development.

The sample application is based on a tutorial but is 4 years old so maybe something has changed.  
(https://www.youtube.com/watch?v=coM6wWKau5E&list=PLPZy-hmwOdEVlrB4r1XF5GDQnaCQpiaa9&index=1)  

Hopefully, it is a simple problem, but I have tried many things without success, so any feedback would be great.  

The application communicates with a back-end service.  For testing, this is the only code used in the back-end controller API.



Thank you for any help



 
Bartender
Posts: 303
12
IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you share the files via GitHub or GitLab instead? It's easier for people to navigate and that way people know what they're clicking on.

It doesn't sound like a JavaFX specific problem (yet), but if you can get it into an easily navigable form like GitHub that'd be helpful. Or alternatively you could put the exact error messages you're getting here.
 
Jeff Dickson
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Updated the main description above with the following link, but will not appear until the edit is approved.

https://github.com/thestorms/SpringBootJavaFx.git
 
Marshal
Posts: 79956
396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please don't edit posts after they have been replied to; that can cause no end of confusion. Please post the resource in a new post.
 
Lou Hamers
Bartender
Posts: 303
12
IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
IntelliJ is acting up for some reason (maybe something to do with Groovy which I don't really use, other than simple Gradle stuff) so I'm out of time to look tonight. So I just looked at the repo briefly.

Normally your JavaFX side would be the client side, but the 'client' folder looks like it has the backend Spring application and the other src folder has your JavaFX stuff (FXML etc.), so maybe it's a project structure problem. When I've done similar things, I've done it as completely separate client and server applications.

I'll probably need to look over the tutorial (which I assume is the YT you linked) when I get a chance, to see what it's trying to do.

Also I could have sworn that JavaFX doesn't work with Spring unless you use FXWeaver (if I recall the name correct) to integrate them. So if the tutorial is doing that differently that's interesting.
 
Jeff Dickson
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for taking a look Lou,  

I restructured it when converting to a github and upgraded to gradle 8.6, but the same problem existed.
The backend is a totally separate service.  I only included the controller method since for testing there is nothing more needed. A blank SpringBoot controller service with the one method added.
The client module in the example is a client to the separate backend service while the app is the JavaFX application.  So basically there are two levels of clients.

To reference the client into the app, the following is used in the build.gradle file which does allow the app to see the classes.

implementation project(":client")

But apparently that is not enough to allow the bean to be found, so the following is needed

client...resources/META-INF/spring.factories which includes

org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.di.client.config.ClientConfig

In the referenced tutorial above, that is when the bean was found in the app.

So basically something about the spring.factories file is not set up correctly is my guess.  

Maybe how gradle is building it or something has changed in Java17 or Java21 which I tested both.



 
Jeff Dickson
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The fix required

replacing spring.factories with META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

I tried this twice but it did not work.  The only difference in my first two attempts was autoconfiguration lower case.
"org.springframework.boot.autoconfigure.autoconfiguration.imports

Spring 3 replaced spring.factories.

https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide#auto-configuration-files

Updated the github project with the solution.
 
Lou Hamers
Bartender
Posts: 303
12
IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok cool so you think you figured it out?

I fixed my IJ issue (maximum heap was set way too low after I switched Linux distros, JVMs really hate running out of memory) but still had some build problems due to the Groovy stuff I think.

...not really a Groovy guy (in any sense, lol).
 
Jeff Dickson
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Currently using SpringBoot and Groovy for most services.  Collect Influx data to evaluate service health.  
Problems are usually memory, number of nodes/capacity, or bugs.  Nothing specific to Groovy.

Glad you found the problem.
 
It is an experimental device that will make my mind that most powerful force on earth! More powerful than this tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic