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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With