Spring bean initialization fails but server start up

When a spring bean(eg Controller) fails in initialization, it propagates exception to FrameworkServlet of spring mvc. For this case, the servlet shuts down bean factory and throws a RuntimeException to web container. However, other servlets are still initialized and the server starts up. The error of FrameworkServlet is ignored.

Is there a way, I can propagate bean creation exceptions or servlet exceptions to other servlets? Can I fail tomcat startup if any of the servlet throws an exception?

Update: Adding a listener as mentioned here (Known way to stop server when spring context failed to load?) fails startup. I get following exception:

org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]

I have my context.xml at this location [/WEB-INF/spring/context.xml], which is configured in web.xml

链接地址: http://www.djcxy.com/p/65352.html

上一篇: 上下文加载但无法启动

下一篇: Spring bean初始化失败,但服务器启动