Chapter 7. Session Bean

Table of Contents

7.1. Stateless Session Bean
7.1.1. Thread Ticket Pool(TTP) and Object Management
7.1.2. Web Service Endpoint
7.2. Stateful Session Bean
7.2.1. Thread Ticket Pool(TTP) and Object Management
7.2.2. Pooling Session Bean
7.2.3. Bean Pool Configuration
7.2.4. Session Data Persistence Mechanism Configuration
7.3. Commonly Used Configuration
7.3.1. Object Management Configuration

This chapter describes stateless session beans and stateful session beans in detail.

The stateless session bean requires no additional configurations other than the ones that were already explained in "Chapter 4. Common Characteristics of EJB". Therefore, this chapter will mainly talk about stateful session beans.

This section describes about the Thread Ticket Pool (hereafter TTP) of session beans.

Stateless session bean does not need to specify a connection pool because it does not have state information related to client requests and all clients share connections. However, because it is stateless and can reuse bean instances, it can use a bean pool.

The following figure shows the relationship of TTP to a bean pool of a stateless session bean.


  1. If TTP receives a request from a connection to a client at the time of creation, it obtains a Thread Ticket. If TTP cannot obtain the TT, it will wait until it receives the TT as described in "Chapter 4. Common Characteristics of EJB". If the wait time exceeds 10 minutes, RemoteException will occur and the request cannot be performed.

  2. TTP gets an actual bean instance from the bean pool and makes a connection to handle the request.

  3. When a stateless session bean instance completes handling the request, the TT is returned to TTP and the bean instance is returned to the bean pool, and waits for the next request. For each request, a TT and a bean instance is allocated and returned.

The size of a bean pool differs from the size of TTP in that it is related to the number of local and remote client requests that can be simultaneously handled. For a remote call, TT is obtained from TTP and then an instance can be obtained from the bean pool. For a local call, since it is performed directly by a client thread, there is no need for a TT and only an instance is obtained from the bean pool.

Therefore, while the number of remote calls that can be handled cannot exceed the value of <thread-max> in jeus-ejb-dd.xml, any number of local calls can be handled because the maximum bean pool size is unlimited.

This section describes additional configurations for stateful session beans.

  • Object management configuration: the bean instance pool and the connection pool

  • Bean instance pooling option

  • State persistence mechanisms through session manager

Since a stateful session bean needs to persistently store state information between client requests, we need to configure and utilize a connection pool (hereafter CP). The same also applies to entity beans. For more information, refer to "Chapter 8. Entity Bean".

The following figure shows the relationship between a bean pool, connection pool, and TTP of a stateful session bean.


If a client creates a stateful session bean, a new bean instance (SF instance) is created and a connection is made between the two through the Connection Pool. If the connection to the bean instance is given to a client, the connection is allocated only to the current client and is not shared with other clients. Therefore, unless the client discards it, it will not be returned to the Connection Pool. When it is returned to the Connection Pool, the connection also gets disconnected from the bean instance.

If a request is sent through the relevant connection, a TT is sent from the TTP. Only the requests that have received a TT are handled. Unlike stateless session beans, a bean instance is not allocated from a bean pool for each request, but a bean instance is assigned for a specific client.

As already mentioned, the bean instance is deleted when it is disconnected because the connection is returned to the Connection Pool when a client discards a bean. Since a stateful session bean contains state information, a bean pool that reuses a bean instance is not used.

This section describes commonly used configuration for stateless and stateful session beans. The configuration is specified in the <jeus-bean> element of the JEUS EJB module DD.

Since stateless session beans do not have state information and a single connection can be used, they can just use the bean pool. However, since stateful session beans have state information, they can use both a connection pool and a bean pool. Therefore, the following settings can be configured for a pool to reduce the load of creating a new instance each time.

The following is an example of XML section related to object management configuration.


Details for sub elements of the <object-management> element.