Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Why all the conspiracy against EJBs?

chandru_inJan 19 2009 — edited Jan 21 2009
Hi,

I see a lot of people (within our organization) claiming EJBs are heavy weight, while Spring is lightweight. And they hate EJBs as if it was the worst sin committed in enterprise Java. I have pretty much been a Spring and Hibernate developer for the past 1.5 years.

But on various blogs I saw positive views of EJB 3.0. So I tried building simple crud stuff using it. I found it surprisingly simpler to develop in than Spring. So, what exactly is the overhead caused by EJB 3.0 which Spring+Hibernate do not suffer from?

To put it more precisely, how do the following two cases differ to make EJB heavier than Spring?

EJB 3.0
1. Stateless EJBs managed by Java EE container.
2. EntityManager injected by container (Glassfish creates another instance of the bean with new EM instance to handle concurrent requests to same bean).
3. Container managed transactions.
4. Accessed using Local interface.
5. Injected using EJB 3.0 annotations.

Spring
1. Singleton beans managed by Spring.
2. A thread-safe proxy of EntityManager injected by Spring.
3. Spring managed transactions.
4. Accessed using Local interface.
5. Injected using Spring XML.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 18 2009
Added on Jan 19 2009
4 comments
268 views