开发者

injected @EJB reference is null after redeployment

开发者 https://www.devze.com 2023-02-18 17:45 出处:网络
I have two ear applications (EJB 3.0) deployed on Jboss 5.1. SLSB from a开发者_运维问答pplication A calls remote SLSBfrom application B via @EJB annotation.

I have two ear applications (EJB 3.0) deployed on Jboss 5.1. SLSB from a开发者_运维问答pplication A calls remote SLSB from application B via @EJB annotation. Everything works fine, until I redeploy application B. Then the bean from A application tries to call the one from B and its reference turns to be null.

I suppose that SLSBs are pooled and references are injected on creation time, and after redeployment those proxies are not refreshed somehow.

How can I cope with that? Is it ok to put an interceptor on that bean and check if all annotated references are not null?


If the application is redeployed/undeployed or there is network failure, the proxy objects are invalidated.

You can use ServiceLocator pattern for caching the references of the remote objects. You can remove & again re-create them with JNDI lookup in case of failure.

Else, instead of using @EJB to inject remote bean, you have to manually lookup each time which is resource consuming, but former is much better approach.

0

精彩评论

暂无评论...
验证码 换一张
取 消