An EJB is a Java component, containing business logic, that you deploy in a container, and that benefits from technical services provided by the container, usually in a declarative way, thanks to annotations:
- transaction management: a transaction can be started automatically before a method of the EJB is invoked, and committed or rollbacked once this method returns. This transactional context is propagated to calls to other EJBs.
- security management: a check can be made that the caller has the necessary roles to execute the method.
- dependency injection: other EJBs, or resources like a JPA entity manager, a JDBC datasource, etc. can be injected into the EJB.
- concurrency: the container makes sure that only one thread at a time invokes a method of your EJB instance.
- distribution: some EJBs can be called remotely, from another JVM.
- failover and load-balancing: remote clients of your EJBs can automatically have their call redirected to another server if necessary.
- resource management: stateful beans can automatically be passivated to disk in order to limit the memory consumption of your server.
- ... I probably have forgotten some points.