O'Reilly logo

EJB 3.1 Cookbook by Richard M. Reese

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a stateless session bean

In this recipe we will create a stateless session bean called SphereBean. This bean will demonstrate the essential elements of a stateless bean and its life cycle. The servlet SphereServlet will be used to demonstrate the bean.

Getting ready

Creating a stateless session bean consists of two steps:

  1. Annotate the class with the @Stateless annotation
  2. Add appropriate business methods

    Earlier versions of EJB required the use of local and/or remote interfaces. This is no longer necessary.

    To use a session bean, inject the EJB into the client using the @EJB annotation followed by the declaration of the bean. In this recipe, we will use a servlet to demonstrate this process. It is important to use the @EJB annotation, otherwise ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required