If you have your web application (for instance, a servlet) deployed in one JVM, and it makes use of EJBs in another JVM on another machine, do the stub and skeleton classes have to be deployed on both machines? Or does the RMIClassLoader mean that these generated classes only have to be deployed on the EJB server?
Your question is very interesting and the answer is not very intuitive (or at least it wasn�t for me). The answer is no, you don�t need the stubs because as you�ve said the server is using the dynamic class loading capabilities provided by the RMI service. Therefore your client servlet needs only to include the home and remote interface classes (along with all other common classes), but no stubs. However in order for this to be true, your container must support dynamic proxies and you must compile the ejb properly. Most of the time your container will provide an rmi compiler (like weblogic.rmic) that is also compatible with older rmi versions. This compiler can also help you to create the ejb stubs for compatibility with the older versions. In that case your servlet client needs to include the generated stubs.
I think, therefore I exist -- Rene Descartes
Joined: Mar 12, 2005
Thanks for the answer. The only thing now I don't understand is, if the remote & home interfaces aren't deployed along with the client code, doesn't that cause a problem with having to import these interfaces in the class which actually does the JNDI lookup and creates the EJB?
Joined: Feb 17, 2005
The home and remote interfaces must be included in both the client and server jars. Is only the traditional RMI stubs and skeletons that don�t need to be generated. [/code]