java ee常见运行错误_java-ee – Java EE应用程序启动失败

如果在应用程序初始化期间发生异常,是否有任何方法来阻止

Java EE应用程序启动?在应用程序初始化期间,从

ServletContextListener或

Singleton

Startup bean抛出的未处理异常之后,我基本上正在寻找一种方法来使应用程序进入“j2ee.state.failed”状态(每

JSR-77).

EJB specification似乎表明,如果在初始化Singleton bean时发生异常,应用程序将继续启动并运行而没有错误;但是,只有bean本身可能处于无法调用的状态.不幸的是,这不是我正在寻找的行为.

4.8.4 Singleton Error Handling

Errors occurring during Singleton initialization are considered fatal and must result in the discarding of the Singleton instance. Possible initialization errors include injection failure, a system exception thrown from a PostConstruct method, or the failure of a PostConstruct method container-managed transaction to successfully commit. If a singleton fails to initialize, attempted invocations on the Singleton result in an exception as defined by Section 3.4.3 and Section 3.4.4.

Servlet specification的要求有点更加模糊,似乎不要求容器以任何特定的方式表现,而只是建议(通过使用术语“可能”)Web模块继续启动,但任何请求都应该产生在内部服务器错误.再次,这不幸不是我正在寻找的行为.如果Web应用程序无法处理任何请求,应该继续启动并显示为运行?

11.6 Listener Exceptions

The container may respond to all subsequent requests to the Web application with an HTTP status code 500 to indicate an application error.

根据我的经验,我看到应用服务器以不同的方式处理这个需求.实际上,有些容器在这些情况下实际上会阻止应用程序启动,而其他的容器将只会抑制异常,并响应500个错误的请求,如规范中所述.

我是否忽略了在初始化过程中发生异常时防止应用程序启动的规范的任何部分?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值