I am fairly new to EJB's and I have a concern about implementing a Session Facade for my application. I understand that one of the primary benefits of a session facade is that the facade will access the entity beans via their local interfaces, and if the client (web) accessed the entity beans directly they would have to do so via remote interfaces which are slower because they use RMI etc. But what if the EJB's will be deployed in a clustered environment? I thought local interfaces could only be used if the beans were guaranteed to be running under the same JVM. Since my app will be running in a clustered WAS environment, does this mean that I can't use local interfaces? And therefore one major benefit of a session facade, is out the window? Any info is appreciated.
There are couple of conditions that need to be met for an application in order to use the local interfaces. First of course implies that the client and the server run in the same jvm (no remote clients). The second is probably less intuitive and implies that both the client and the server must be loaded by the same classloader. For example at least in theory, deploying the web app and the ejbs in the same ear will meet the last condition, while deploying them as separate war and jar(s) won�t. To answer to your question, you definitely can use local interfaces, if you web components and your ejbs are packed together in the same ear. This will work in a cluster environment as well. The trick is that once an http request was send to one web app in the cluster, the server will always use special algorithms to improve the performances for collocated ejb objects. Subsequently all other calls for the same client/thread will be redirected to ejbs located on the same server (the request never lives the current server).