@Startup @Singleton instantiated twice in WebLogic (EJB 3.1)

泄露秘密 提交于 2019-12-06 03:51:48

The first stack is not actually creating a bean instance but a proxy instance. Your @Singleton does not declare any business interfaces, so by default it uses the no-interface view (which can be explicitly configured using @LocalBean). When using the no-interface view, the container generates a proxy class that is a subclass of your class (in this case, the proxy is named CacheStartupListener_m3hhum_NoIntfViewImpl). When the container creates an instance of this proxy subclass, the constructor of your EJB class will be invoked. You can try printing getClass() in your constructor to prove this point.

I strongly recommend removing the Java constructor altogether and moving all initialization logic to @PostConstruct. Java constructors do not mix well with no-interface view.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!