We've strived to keep this topic practical without skimping on content. The topic is de-
signed to help you learn EJB 3 quickly and easily without neglecting the basics. We'll also
dive into deep waters, sharing all the amazing sights we've discovered and warning about
any lurking dangers.
In the Java world EJB is an important and uniquely influential technology radically trans-
formed in version 3. We'll spend little time with EJB 2. You probably either already know
earlier versions of EJB or are completely new to it. Spending too much time on previous
versions is a waste of time. EJB 3 and EJB 2 have very little in common, and EJB 3.2 now
makes support for EJB 2 optional. But if you're curious about EJB 2, we encourage you to
pick up one of the many good topics on the previous versions of EJB.
In this chapter we'll tell you what's what in EJB 3, explain why you should consider using
it, and outline the significant improvements the newest version offers, such as annotations,
convention-over-configuration, and dependency injection. We'll build on the momentum
of this chapter by jumping into code in chapter 2 . Let's start with a broad overview of EJB.
1.1. EJB overview
The first thing that should cross your mind while evaluating any technology is what it
really gives you. What's so special about EJB? Beyond a presentation-layer technology
like JavaServer Pages (JSP), JavaServer Faces (JSF), or Struts, couldn't you create your
web application using the Java language and some APIs like Java Database Connectivity
(JDBC) for database access? You could—if deadlines and limited resources weren't real-
ities. Before anyone dreamed up EJB, this is exactly what people did. The resulting long
hours proved that you'd spend a lot of time solving very common system-level problems
instead of focusing on the real business solution. These experiences emphasized that there
are common solutions for common development problems. This is exactly what EJB brings
to the table. EJB is a collection of “canned” answers to common server application de-
velopment problems, as well as a roadmap to common server component patterns. These
canned solutions or services are provided by the EJB container. To access these services,
you build specialized components using declarative and programmatic EJB APIs and de-
ploy them into the container.