Reputation: 6494
I want my web application to fail on startup if any of my servlet fails to initialize.
I would expect if I throw an exception form the Servlet.init()
method it would cause the entire app to fail, but apparently it doesn't. The web container (Tomcat 7 in my case) just fails to load that particular servlet, but the application is reported to be successfully deployed anyway.
It behaves as expected if an exception thrown from e.g. ServletContextListener.contextInitialized()
method, but why the exception thrown from the Servlet.init()
doesn't have this effect?
Is there any way to stop the application in case of a Servlet initialization error?
Upvotes: 2
Views: 2072
Reputation: 15446
Try this following steps:
Upvotes: 3