- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在阅读 EJB 规范
,我对我的观点的矛盾感到困惑,特别是关于 Container
在 System Exception 时的行为方式
在Singleton Bean
的生命周期回调方法中被抛出。
第 12.3.1 节:
A runtime exception thrown by any lifecycle interceptor callback method causes the bean instance and its interceptors to be discarded after the interceptor chain unwindsce and any associated interceptor instances are discarded (except for Singleton Beans).
第 4.8.4 节:
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.
Unlike instances of other component types, system exceptions thrown from business methods or callbacks of a Singleton do not result in the destruction of the Singleton instance.
那么,根据第 4.8.4 节,什么是正确的?如果在 @PostConstruct
方法或 Interceptor
@PostConstruct
方法中抛出 System Exception
是 Bean
被丢弃?我试过它抛出 EJBException
,结果是 Beans 初始化失败。
更令人惊讶的是,当从 Singleton Bean
Business Method 中抛出 EJBException
时,客户端收到了 Exception
并且没有进一步执行其他方法。我可以假设 Bean 实例被丢弃了吗?根据规范,不应导致 Bean 实例
的破坏。在这两种情况下,什么是正确的?
最佳答案
我要求提供代码,因为这可能是供应商错误。正如您阅读的那样,如果在 @PostContruct 时出现 EjbException,则不会构建单例。在那之后,单例方法可以抛出任何类型的异常(已检查或未检查)并且实例应该仍在运行。
拦截器生命周期附加到单例生命周期,因此,如果拦截器无法执行其@PostContruct,则不会创建单例。
要记住的另一件事是:如果 EJB(@Stateless 或 @Stateful)抛出 EjbException(或其拦截器),该实例会自动被丢弃,因此,规范中有一条注释说: [58] 单例除外。参见第 4.8.4 节
关于java - 单例 EJB 中的系统异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21802575/
我最近购买了《C 编程语言》并尝试了 Ex 1-8这是代码 #include #include #include /* * */ int main() { int nl,nt,nb;
早上好!我有一个变量“var”,可能为 0。我检查该变量是否为空,如果不是,我将该变量保存在 php session 中,然后调用另一个页面。在这个新页面中,我检查我创建的 session 是否为空,
我正在努力完成 Learn Python the Hard Way ex.25,但我无法理解某些事情。这是脚本: def break_words(stuff): """this functio
我是一名优秀的程序员,十分优秀!