JBoss.org Community Documentation

Chapter 2. Introduction to EJB3 Stateless Beans

It is very easy to create a Stateless Bean with EJB 3.0. All bean types are homeless in EJB 3.0 so all you have to do to create a Stateless bean is to create a bean class and have it implement at least one interface. Take a look at org.jboss.tutorial.stateless.bean.CalculatorBean

The first thing to notice is that the class is tagged as @Stateless. This marks the class as a stateless bean and the deployer will deploy that class as a stateless bean EJB container.

CalculatorBean also implements two interfaces. One is the remote interface of the EJB the other is the local interface.

Take a look at org.jboss.tutorial.stateless.bean.CalculatorRemote. To define this as the remote interface of Calculator bean you either annotate the bean class and specify what the remote interfaces are, or you annotate each remote interface the bean class implements with @javax.ejb.Remote. only need to annotate the bean class with @javax.ejb.Remote. Similar for org.jboss.tutorial.stateless.bean.CalculatorLocal as you need to annotate the bean class with @javax.ejb.Local for it to be the local interface of the CalculatorBean.

JNDI Bindings

The Calculator bean will have two JNDI bindings for the remote and Local interface. By default, JBoss will use ejbName/local and ejbName/remote for the local and remote interfaces, respectively.