Originally posted by Jeanne Boyarsky:
Session beans aren't as heavyweight as they used to be. They are still heavier than POJOs. They also do more.
What more do the session beans do when compared to POJOs? Starting from Transactions, concurrency, pooling, dependency injection, security, all of these are available on the POJOs too with a container like Spring,
minus the component/remote interface and implementation object, home interface and implementation object (EJB3 containers still create a component object for each bean) and minus JNDI lookups.
Originally posted by Jeanne Boyarsky:
If you require the services that EJB provides, it is a great fit. If not, it is overkill. This has been true all along.
Were EJBs were a great fit all along ? If you look at the EJB spec until 2.1. EJBs had to extend a SessionBean or EntityBean making it impossible to map on the domain model in the design phase directly onto the session or entity beans. (because Java does not support multiple inheritance). :-(. In EJB 3 finally Sun has come out with the ability to insert those EntityBean and SessionBean classes through dependency injection so that the programmer is free to extend a class of his choice. But unfortunately Spring was already out before EJB3 based J2EE containers were available. So my question was, why is Sun re-inventing the wheel again :-(, when there were other aspects of the Java platform that it can address?
Also by the way, we have seen various studies showing that Tomcat is the mainstream enterprise Java platform (web container without EJB), instead of the full blown J2EE containers like Weblogic, Websphere etc. Customers do not like bloated vendor products, they like lightweight, agile frameworks, which I don't think EJB 2.1. was (Gosh, dont even get me started on Entity Beans 2.1 ;-)).
I have built enterprise apps on both Weblogic (with EJB 3) and Tomcat (with Spring) and I repeatedly find Tomcat and Spring is more simpler to configure and more powerful to use than EJB3 and Weblogic (I am not a Spring fanboy btw, there are still some aspects of Spring that I don't favor a lot).
I am not saying Sun is not doing a proper job, but EJB has a exceedingly rare usage (when compared to JSP and Servlets, 80% - 20% probably) for the upcoming and current development projects so I frankly dont think that EJB should enjoy the luxury of being an integral part of the Java EE platform.
Thankfully Sun is coming up with profiles in the Java EE 6 spec, so that if customers dont need EJBs in their app-server, they can download the version without support for EJBs, to make their environment more lightweight and performance oriented.