首页 > 解决方案 > 如果 servlet 上下文初始化失败,则跳过部署或停止 Web 应用程序

问题描述

在我们的项目中,我们有几个基于 Spring 的模块作为 Web 应用程序部署在 WAS 上。ContextLoaderListener#contextInitialized如果 Spring 上下文初始化失败(即或DispatcherServlet#init抛出异常),我们需要跳过部署或停止模块。现在,如果发生这种情况,应用程序将被部署并启动,但对于任何请求都会返回 HTTP 500。

Websphere 8.5.5

相关问题:https ://stackoverflow.com/a/272747/3459206

标签: javaservletsweb-applicationswebsphere

解决方案


这个 APAR 似乎是相关的:

https://www-01.ibm.com/support/docview.wss?uid=swg1PI58875

从 APAR 文本:

Listener exceptions typically should not stop the application
from starting up for service. However, some applications depend
on their listeners to do the necessary setup before the
application is started for service. Such applications prefer to
stop the application from starting up when there is any
exception in their listeners.

问题结论

The WebContainer Container code was modified to provide an
option to stop the application when there is any listener
exception during the application starting up process.

A new WebContainer custom property needs to be set to enable the
behavior provided by this APAR:

For Full Profiles

com.ibm.ws.webcontainer.stopappstartuponlistenerexception = true
(default is false)

For Liberty Profile

stopappstartuponlistenerexception=true

The fix for this APAR is currently targeted for inclusion in
WebSphere Application Server fix packs 8.5.5.11 and  9.0.0.2,
and Liberty 16.0.0.3

有关其他信息,请参阅 APAR 链接。


推荐阅读