This is one of the most asked question at this time. The EJB3 specification has incopored interesting concepts and ideas from leading open source projects to make easier to use, remove lines of code and improve the time of application development.
Spring and EJB3 together
I think that these two technologies don't make exactly the same things and it's a great things to use them together.
There are two parts:
- Access EJB with Spring.
- Use Spring in EJB (transaction, components).
Spring permit to build well-defined applications both in an application server and outside/without an application server. This framework underlines that you need to use the appropriated technology for your application: do you really need ejb / jta technologies? Is a servlet container enough? Local or global transactions?
It focuses too on best pratices and design patterns to have a flexible, modular, reusable applications.
EJB3 will surely be easier to use but the technology needs too to have best pratices and design patterns...
Finally, before asking using Spring or EJB3, you may wonder which kind of applications, you need to develop. Then you can choose the appropriate technology(ies)!
Spring, not a specification...
Finally, I think the important thing against is that Spring isn't a specification but EJB3 is...
Made you your opinion with the following readings!!!
Some threads in the Spring forum on this subject:
EJB3.0 without Spring :-)
An article on the onjava site on this subject:
POJO Application Frameworks: Spring Vs. EJB 3.0
Some insteresting blog entries on that subject:
The EJB cult Part 3 - Integrating Spring and EJB 3.0 dependency injection
Spring, EJB 3, and the future
A interesting article of Rob Harrop and Jan Machacek on Spring / EJB integration:
Pro Spring: Spring and EJB
The EJB section of the Spring 1.2.x reference documentation:
Accessing and implementing EJBs