# The Java EE 7 Tutorial

# 34 Running the Enterprise Bean Examples

This chapter describes the EJB examples. Session beans provide a simple but powerful way to encapsulate business logic within an application. They can be accessed from remote Java clients, web service clients, and components running in the same server.

In Chapter 33, "Getting Started with Enterprise Beans", you built a stateless session bean named `ConverterBean`. This chapter examines the source code of four more session beans:

- `CartBean`: a stateful session bean that is accessed by a remote client

- `CounterBean`: a singleton session bean

- `HelloServiceBean`: a stateless session bean that implements a web service

- `TimerSessionBean`: a stateless session bean that sets a timer

The following topics are addressed here:

- The cart Example

- A Singleton Session Bean Example: counter

- A Web Service Example: helloservice

- Using the Timer Service

- Handling Exceptions