views:

136

answers:

2

I have an upcoming project in a class that will allow me to work with either EJBs or Spring, and I was wondering what would be more applicable for "real world" situations.

+3  A: 

The two technologies aren't mutually exclusive. And when you say EJBs it depends on if you're talking about session beans or entity beans (or message driven beans for completeness).

Stateless session beans are and always have been quite useful if for no other reason than they provide a reasonably consistent and low barrier-to-entry to distributed transactions.

EJB3 also takes a leaf out of Spring's book with some dependency injection features.

That being said, this has been a long-running cause of dispute.

It's probably worth reading some of the (many) comparisons on the Web such as this one.

It's really hard to recommend one over the other without knowing your requirements. Personally I favour Spring though unless I've got a good reason not to.

cletus
I'm guessing by your last line that you would suggest that I take the Spring activity as my assignment?
Thomas Owens
In the absence of any particular requirement that might sway me one way or the other, I will tend to favour Spring, yes. I'm just trying to convey that this isn't a black and white issue. There are valid reasons to choose each in different situations.
cletus
+2  A: 

Spring took a completely different (and vastly improved) approach to some of the problems that EJB2 was designed to solve. The along came EJB3, which bears an uncanny resemblence to the Spring approach - not that the likes of Sun or JBoss will admit it.

Despite the similarity, EJB3 and Spring are not solving the same problems. EJB3 provides a component programmic model and framework, whereas Spring is more of a toolbox that provides consistent solutions for many cross-cutting concerns such as transaction management and remoting. EJB3 provides more structure out of the box, but the flipside of this is that it becomes more restrictive.

skaffman