I have a web application which I'm trying to shut down by executing the close()
method on the context:
((ConfigurableApplicationContext) appContext).close();
After executing this the application appears to be continuing running, health page produces the following exception:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978)
Is there a way to shudown the whole thing via Spring or should I resort to System.exit()
?
Any help would be kindly appreciated!
PLease have a look at these questions. They are on the same line as yours: How to manage Tomcat via Java, Start / stop a web application from itself?
As @chrylis suggested, I think the easiest way of shutting down the server(if it's not running in embedded mode) is to use Runtime class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With