Name

Everything Is an EJB

Mistake

EJBs are used when they provide few benefits, leading to an unnecessarily bloated or complex application.

Watch for It When

EJB features such as CMP, transactions, or security are not needed, few clients access the business tier, entity beans are simply a wrapper to an existing database, session beans are used as a gateway to other remote services, or business services do not need to be distributed.

Solution

Often entity beans can be replaced with local commands or JavaBeans working in conjunction with DAOs. Direct database access, flat files, and JDO can also provide lighter-weight persistence mechanisms than entity EJBs.

Session EJBs can often be replaced with business delegates or other, non-EJB façades.

Get J2EE Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.