When starting a boot web application on the console through Maven
mvn spring-boot:start
and then shutting it down
mvn spring-boot:stop
it fails with
Spring application lifecycle JMX bean not found (fork is null).
The documentation states that fork
is true
by default which seems not to be the case here.
Comment From: snicoll
spring-boot:stop
uses whatever value was used by the start process. When maven runs, the start goal runs first and then sets the value it has used to start the app. When the stop goal runs later, it reads that value from the context. Therefore, if the application is started with the default settings (or fork=true), then it's trying to stop it as a forked process. If the application is started with fork=false, then it is trying to stop it in the current process. Strictly speaking, the documentation is accurate in that regard. It states that the fork has no default value, it doesn't for the reason I've expressed above.
What is particular about your use case is that you're using these goals in isolation. The mechanism I have described above doesn't work. You run maven first, which sets the fork value in the context, then the process exit. Then later on, you fire up a brand new maven process to stop the app that doesn't have the context. It can't read the fork value from the context, so fork
is null
.
The reason why we have a bug here is that spring-boot:stop
uses false
when it doesn't find the fork value that the start process has put in the context. For consistency it should use true
rather.