First reactions to EJB 3.0

After my first real exposure to programming EJB3.0, I'm pleasantly surprised to find them less complex and more easy to use.

I've been heads down the last week working on an assignment to give my Large Scale Distributed Systems class.  Normally, I wouldn't spend that much time on any given assignment, but I wanted the assignment to be based on EJB3.0 and this was my first exposure to the new specification. 

JBoss supports EJB3.0 in version 4 of their server, but you have to add in some additional JAR files to make it work. I'm not familiar with the level of support for EJB3.0 in other application servers.  If you know something, leave a comment.

As I said, I've only been playing with EJB3.0 for a few weeks, but I have a few initial reactions:

  • First and foremost, the beans in EJB3.0 are significantly less complex.  Entity beans are just plain old Java objects (POJOs) and the container manages the mapping of these objects to a relational database and the persistence of POJOs to the database.  For example, the interfaces for EJBs do not have to implement EJBObject or EJBLocalObject. In addition, lifecycle methods like ejbPassivate, ejbActivate, ejbLoad, ejbStore, etc. are no longer required.
  • The metadata annotation feature of Java 1.5 is put to use in annotating entity and session beans to give hints as to the behaviors that you want from the bean. In the past I've used XDoclet to simplify bean building, but EJB3.0 doesn't require it because of the annotations.
  • While I've not done any performance tests, they seem faster.  Now in addition to moving to EJB3.0, I also moved from JBoss 3 to JBoss 4 and that could be the difference.
  • The change to POJOs for entity beans has been advertised as Hibernate in EJB, but you don't feel like you're using Hibernate; the connection is more conceptual than anything else.  I've only used the mapping from entity objects to the relational table, not the other way around. 
  • Documentation is sparse.  There's been lots of questions that I've had trouble finding answers to.  I'm sure that will change.  As long as your application follows the few examples fairly closely, you'll be able to gather what to do from them, but that only goes so far. 
I'm sure I'll have more as I work with EJB3.0 more over the next few weeks, but all in all, I'm happy with what I've seen.   Normally, I'd be reluctant to use something this bleeding edge as part of an undergraduate assignment, but on balance, I thought the greater simplicity was worth the potential trouble that this might cause.  In the past, the complexity of EJBs have made them difficult to understand in the short time we have to cover this important topic.  The concepts are hard enough all by themselves.   I'll keep you updated on my experience.