Just as Hibernate attacks CMP as primitive ORM technology, Spring attacks EJB, it says EJB is complicated
and not susceptible to unit-testing.

Instead of EJB, Spring suggests that we make use of ordinary Java beans, with some slight modifications, to get
all the supposed advantages of EJB environment.

Thus, Spring is borne as an alternative to EJB essentially. However, as a concession to the existing EJB
investments, Spring is designed to operate with EJB if required.

The main aim of Spring is to simplify the J2EE development and testing.

The main advantages of EJB2 are:

a) Transaction Management
b) Declarative Transaction support
c) Persistence ( CMP & BMP)
d) Declarative Security
e) Distributed Computing (Container managed RPC)


Spring does not attempt to do everything by itself but supports the best of breed technologies for each of these
requirements.
1. Instead of CMP & BMP, it supports several persistence technologies like JDO, Hibernate and OJB.
These ORM tools are far more capable than the implementation in CMP.
2. Spring makes use of Acegi, an open-source Security framework and provides declarative security
through spring configuration file
3. Spring provides proxying for RMI (special remoting technologies like Burlap) JAX-RPC & webservice
while EJB provides container-managed remote method calls.
4. Spring can offer declarative transaction like EJB. But spring provides declarative rollback behavior also
,for methods and exceptions

Thereby, it gives the following advantages over EJB2.
1. Testing is easier. We do not need to start the EJB container , for testing.
2. As Spring is based on the standard JavaBeans naming convention, programmers find it.
3. It makes use of AOP(Aspect-Oriented Programming) which is a very recent and useful paradigm.
4. It is flexible.