Last night I attended a New England Java User Group (NEJUG) meeting where Reza Rahman presented a "comparative analysis" of EJB 3 and Spring. Reza is one of the authors of EJB 3 in Action. I enjoyed meeting Reza and respect him for presenting what may be considered a controversial topic. I will provide brief responses to 10 "themes" of the presentation. 1. EJB uses annotations for metadata. Spring uses XML. 2. Spring allows you to support multiple deployment environments but requires more configuration. 3. EJB with JPA, Spring with Hibernate 4. Spring makes no assumptions, you have to provide configuration. 5. Spring does not have a stateful application paradigm. 6. Spring requires configuration of a container per MessageListener. 7. Concurrent Consumers cannot be greater than 1. 8. Spring's usage of the AspectJ expression language is powerful but cryptic. 9. Spring tool support has been sparse. 10. With EJB as a standard, you can migrate from one vendor to another. With Spring, you still have to port the metadata.Read Mark's complete post: http://blog.interface21.com/main/2007/11/09/a-response-to-ejb-3-and-spring-comparative-analysis/
Reza Rahman -- an EJB 3 book author -- recently presented a comparative analysis on EJB 3 and Spring at a Java User Group meeting. Present at that same meeting was Mark Fisher of the Spring team, which in this blog entry provides a point by point response to the former presentation. An interesting read for anyone using EJB 3 or Spring, as it provides points of view from experts on both subjects.
- Posted by: Daniel Rubio
- Posted on: November 23 2007 20:05 EST
Note also that Spring 2.5 is now GA, so much of this comparison is out of date (quite apart from the many other valid points Mark makes). In particular, the equation of Spring with XML, EJB with annotations is invalid today:
- Spring 2.5 supports all the annotation-driven injection of EJB 3.0 and more, with its support for @Resource injection allowing resolution to objects other than JNDI references, and allowing mixing of Spring-style injection with EJB injection
- Spring 2.5 extends its own "autowiring" capability to annotations with the @Autowire annotation, which far exceeds the power of @Resource
- Often you do need to externalize configuration from Java code, and you will find then that Spring's XML and properties configuration mechanism is intuitive and proven, while EJB XML configuration is verbose and clunky.