question first for those in a hurry:
Should I define a separate ServletWebServerFactory bean for the plugin? Or do I want it to ignore looking for it since it seems to work just fine with the root app's servlet factory
Further details:
Exception in thread "main" org.springframework.context.ApplicationContextException:
Unable to start web server; nested exception is
org.springframework.context.ApplicationContextException: Unable to start
ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
at grails.boot.GrailsApp.run(GrailsApp.groovy:99)
I have a multi-project grails app. Root app loads a plugin with the profile "web-plugin"
grails:
profile: web-plugin
I generated the plugin scaffolding using the default grails command line ( grails create-plugin), so most settings are default for grails 5.
When I run the main app, it builds and starts the plugin first. When it hits the plugin's generated Application.main method, it blows up
@PluginSource
class Application extends GrailsAutoConfiguration {
static void main(String[] args) {
//blows up here saying there is no ServletWebServerFactory bean
GrailsApp.run(Application, args)
}
}
Then, the root app- which has the ServletWebServerFactory Bean defined - starts fine. From the running root app I can access and run the plugin endpoints even though it encountered the exception..
How should I address the error? To repeat the question: Should I define a separate ServletWebServerFactory bean for the plugin? Or do I want it to ignore looking for it since it seems to work just fine with the root app's servlet factory?
No.
If your dependencies are configured correctly I don't expect you will have the problem if you run the
mainmethod in the app (as distinct from the plugin).