3
votes

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?

1
I seem to have the same problem with EJB injection on JBoss 6, and (so far) only after redeploys. - Matt Ball

1 Answers

1
votes

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.