Could u please give clear idea of what is RMI and EJB.
Both are used for invoking remote methods?
RMI is an integral part of EJB. RMI is used as standard API for many distributed objects in EJB. In EJB Enterprise beans are made available for remote clients using RMI.
well, RMI is Remote Method Invocation. Its a protocol by which distributed objects can communicate with each other. Sun Microsystems has provided Java implementation of this RMI protocol. There could be many implementations of RMI.
EJB, Enterprise JavaBeans, is a distributed component model provided by Sun Microsystems. EJB is based on RMI protocol and it uses Java RMI as core implementation. You can say, EJB is 10 steps ahead of Java RMI with its many features like creating components, deploying them into application server and many other features.
As you noted, using EJB really looks like RMI. It is natural
because the underlying network protocol of EJB is RMI-IIOP which is used to implement remote method invocation. You can
also find that the methods in EJB remote interface are required to throw RemoteException and the arguments must have seriolizable or primitive data type-- which are very much like the rmi requirements. Also EJB container generates
stubs/skeletons which are also generated by rmic.
But, EJB goes far beyond RMI.
First, the underlying network protocol of EJB1.1 is RMI-IIOP, rather than RMI. RMI-IIOP is an extension of RMI protocol. (To see the difference, refer to Rodman's Mastering EJB book).
Second, RMI-IIOP is just a network protocol, while EJB container is a powerful software package built upon this protocol. When you use EJB, the EJB container can do a lot of things, such as bean management, transaction managment, resource managment etc. All of these managment are transparant to EJB programmers who does not need to worry about synchorization and concurrency which are big problems for system programmmers.