Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

injected @EJB reference is null after redeployment

I have two ear applications (EJB 3.0) deployed on Jboss 5.1. SLSB from application 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?

like image 872
veilsoen Avatar asked Feb 20 '26 08:02

veilsoen


1 Answers

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.

like image 57
Nayan Wadekar Avatar answered Feb 26 '26 06:02

Nayan Wadekar