Sun Java System Application Server Enterprise Edition 8.1 2005Q2 Administration Guide

- Previous: Chapter 7 Connector Resources
- Next: Chapter 9 Configuring Security

# Chapter 8 J2EE Containers

This chapter explains how to configure the J2EE containers included in the server. This chapter contains following sections:

- About the J2EE Containers

- Admin Console Tasks for the J2EE Containers

# About the J2EE Containers

This section describes the J2EE containers included with the Application Server.

- Types of J2EE Containers

- The Web Container

- The EJB Container

## Types of J2EE Containers

J2EE containers provide runtime support for J2EE application components. J2EE application components use the protocols and methods of the container to access other application components and services provided by the server. The Application Server provides an application client container, an applet container, a Web container, and an EJB container. For a diagram that shows the containers, see the section Application Server Architecture.

## The Web Container

The Web Container is a J2EE container that hosts web applications. The web container extends the web server functionality by providing developers the environment to run servlets and JavaServer Pages (JSP files).

## The EJB Container

Enterprise beans (EJB components) are Java programming language server components that contain business logic. The EJB container provides local and remote access to enterprise beans.

There are three types of enterprise beans: session beans, entity beans, and message-driven beans. Session beans represent transient objects and processes and typically are used by a single client. Entity beans represent persistent data, typically maintained in a database. Message-driven beans are used to pass messages asynchronously to application modules and services.

The container is responsible for creating the enterprise bean, binding the enterprise bean to the naming service so other application components can access the enterprise bean, ensuring only authorized clients have access to the enterprise bean’s methods, saving the bean’s state to persistent storage, caching the state of the bean, and activating or passivating the bean when necessary.

# Admin Console Tasks for the J2EE Containers

- Configuring the General Web Container Settings

- Configuring the General EJB Settings

- Configuring the Message-Driven Bean Settings

- Configuring the EJB Timer Service Settings

## Configuring the General Web Container Settings

In this release, there are no container-wide settings for the Web container in the Admin Console.

## Configuring Web Container Sessions

This section describes the HTTP session settings in the Web container. HTTP sessions are unique web sessions that have their state data written to a persistent store.

- To set the session timeout value

- To configure the manager properties

- To configure the store properties

### To set the session timeout value

1. In the tree component, select the Configurations node.

2. Select the instance to configure:

   - To configure a particular instance, select the instance’s config node. For example, the default instance, `server`, select the `server-config` node.

   - To configure the default settings for all instances, select the `default-config` node.

3. Select the Web Container node.

4. Click the Session Properties tab.

5. In the Session Timeout field, enter the number of seconds that a session is valid.

6. Click Save.

### To configure the manager properties

The session manager provides the means to configure how sessions are created and destroyed, where session state is stored, and the maximum number of sessions.

To change the session manager settings:

1. In the tree component select the Configurations node.

2. Select the instance to configure:

   - To configure a particular instance, select the instance’s config node. For example, the default instance, `server`, select the `server-config` node.

   - To configure the default settings for all instances, select the `default-config` node.

3. Select the Web Container node.

4. Click the Manager Properties tab.

5. Set the Reap Interval value.

   The Reap Interval field is the number of seconds before the inactive session data is deleted from the store.

6. Set the Max Sessions value.

   The Max Sessions field is the maximum number of sessions allowed.

7. Set the Session Filename value.

   The Session Filename field is the file that contains the session data.

8. Set the Session ID Generator Classname value.

   The Session ID Generator Classname field allows you to specify a custom class for generating unique session IDs. Only one session ID generator class per server instance is permitted, and all instances in a cluster must use the same session ID generator to prevent session key collision.

   Custom session ID generator classes must implement the `com.sun.enterprise.util.uuid.UuidGenerator` interface:

       package com.sun.enterprise.util.uuid;

       public interface UuidGenerator {

           public String generateUuid();
           public String generateUuid(Object obj);  //obj is the session object
       }

   The class must be in the Application Server classpath.

9. Click Save.

### To configure the store properties

1. In the tree component, select the Configurations node.

2. Select the instance to configure:

   - To configure a particular instance, select the instance’s config node. For example, the default instance, `server`, select the `server-config` node.

   - To configure the default settings for all instances, select the `default-config` node.

3. Select the Web Container node.

4. Click the Store Properties tab.

5. Set the Reap Interval.

   The Reap Interval field is the number of seconds before the inactive session data is deleted from the store.

6. Click Save.

## Configuring the General EJB Settings

This section describes the following settings, which apply to all enterprise bean containers on the server:

- Session Store Location

- To configure EJB pool settings

- To configure EJB cache settings

To override the defaults on a per-container basis, adjust the values in the enterprise bean’s `sun-ejb-jar.xml` file. For details, see the Application Server Developer’s Guide.

### Session Store Location

The Session Store Location field specifies the directory where passivated beans and persisted HTTP sessions are stored on the file system.

Passivated beans are enterprise beans that have had their state written to a file on the file system. Passivated beans typically have been idle for a certain period of time, and are not currently being accessed by clients.

Similar to passivated beans, persisted HTTP sessions are individual web sessions that have had their state written to a file on the file system.

The Commit Option field specifies how the container caches passivated entity bean instances between transactions.

Option B caches entity bean instances between transactions, and is selected by default. Option C disables caching.

### To configure EJB pool settings

The container maintains a pool of enterprise beans in order to respond to client requests without the performance hit that results from creating the beans. These settings only apply to stateless session beans and entity beans.

If you experience performance problems in an application that uses deployed enterprise beans, creating a pool, or increasing the number of beans maintained by an existing pool, can help increase the application’s performance.

By default, the container maintains a pool of enterprise beans.

1. In the tree component, select the Configurations node.

2. Select the instance to configure:

   - To configure a particular instance, select the instance’s config node. For example, the default instance, `server`, select the `server-config` node.

   - To configure the default settings for all instances, select the `default-config` node.

3. Select the EJB Container node.

4. Under Pool Settings in the Initial and Minimum Pool Size field enter the minimum number of beans the container creates in the pool.

5. In the Maximum Pool Size field enter the maximum number of beans the container maintains in the pool, at any time.

6. In the Pool Resize Quantity field enter the number of beans that will be removed from the pool if they are idle for more than the time specified in Pool Idle Timeout.

7. In the Pool Idle Timeout field enter the time, in seconds, that a bean in the pool can remain idle before it will be removed from the pool.

8. Click Save.

9. Restart the Application Server.

### To configure EJB cache settings

The container maintains a cache of enterprise bean data for the most used enterprise beans. This allows the container to respond more quickly to requests from other application modules for data from the enterprise beans. This section applies only to stateful session beans and entity beans.

Cached enterprise beans are in one of three states: active, idle, or passivated. An active enterprise bean is currently being accessed by clients. An idle enterprise bean’s data is currently in the cache, but no clients are accessing the bean. A passivated bean’s data is temporarily stored, and read back into the cache if a client requests the bean.

1. In the tree component, select the Configurations node.

2. Select the instance to configure:

   - To configure a particular instance, select the instance’s config node. For example, the default instance, `server`, select the `server-config` node.

   - To configure the default settings for all instances, select the `default-config` node.

3. Select the EJB Container node.

4. Adjust the maximum cache size in the Max Cache Size field.

   Increase the maximum number of beans to cache to eliminate the overhead of bean creation and destruction. However, if the cache is increased, the server consumes more memory and resources. Be sure your operating environment is sufficient for your cache settings.

5. Adjust the cache resize quantity in the Cache Resize Quantity field.

   When the maximum number of cached beans is reached, the container removes a number of passivated beans from the backup store, set to 32 by default.

6. Adjust the rate, in seconds, at which the cache cleanup is scheduled for entity beans in the Cache Idle Timeout field.

   If a cached entity bean has been idle a certain amount of time, it is passivated. That is, the bean’s state is written to a backup store.

7. Adjust the time, in seconds, after which stateful session beans are removed from the cache or passivated store in the Removal Timeout field.

8. Configure the policy the container uses to remove stateful session beans in the Removal Selection Policy field.

   The container decides which stateful session beans to remove based on the policy set in the Removal Selection Policy field. There are three possible policies the container uses to remove beans from the cache:

   - Not recently used (NRU)

   - First in, first out (FIFO)

   - Least recently used (LRU)

   The NRU policy removes a bean that hasn’t been used recently. The FIFO policy removes the oldest bean in the cache. The LRU policy removes the least recently accessed bean. By default, the NRU policy is used by the container.

   Entity beans are always removed using the FIFO policy.

9. Click Save.

10. Restart the Application Server.

## Configuring the Message-Driven Bean Settings

The pool for message-driven beans is similar to the pool for session beans described in To configure EJB pool settings. By default, the container maintains a pool of message—driven beans.

To adjust the configuration of this pool:

### To configure MDB pool settings

1. In the tree component, select the Configurations node.

2. Select the instance to configure:

   - To configure a particular instance, select the instance’s config node. For example, the default instance, `server`, select the `server-config` node.

   - To configure the default settings for all instances, select the `default-config` node.

3. Select the EJB Container node.

4. Click the MDB Settings tab.

5. Under Pool Settings in the Initial and Minimum Pool Size field, enter the minimum number of message beans the container creates in the pool.

6. In the Maximum Pool Size field, enter the maximum number of beans the container maintains in the pool, at any time.

7. In the Pool Resize Quantity field, enter the number of beans that are removed from the pool if they are idle for more than the time specified in Pool Idle Timeout.

8. In the Pool Idle Timeout field, enter the time, in seconds, that a bean in the pool can remain idle before it is removed from the pool.

9. Click Save.

10. Restart the Application Server.

## Configuring the EJB Timer Service Settings

The timer service is a persistent and transactional notification service provided by the enterprise bean container used to schedule notifications or events used by enterprise beans. All enterprise beans except stateful session beans can receive notifications from the timer service. Timers set by the service are not destroyed when the server is shut down or restarted.

### To configure the Timer Service

1. In the tree component, select the Configurations node.

2. Select the instance to configure:

   - To configure a particular instance, select the instance’s config node. For example, the default instance, `server`, select the `server-config` node.

   - To configure the default settings for all instances, select the `default-config` node.

3. Select the EJB Container node.

4. Click the EJB Timer Service tab.

5. Set the minimum delivery interval in milliseconds in the Minimum Delivery Interval field.

   Minimum Delivery Interval is the minimum number of milliseconds allowed before the next timer expiration for a particular timer can occur. Setting this interval too low can cause server overload.

6. Set the maximum number of attempts the timer service makes to deliver the notification in the Maximum Redeliveries field.

7. Set the interval, in milliseconds, between redelivery attempts in the Redelivery Interval field.

8. Click Save.

9. Restart the Application Server.

### To use an external database with the Timer Service

The timer service by default uses an embedded database to store timers.

1. Set up a JDBC resource for the database, as described in To create a JDBC resource.

2. Enter the JNDI name of the resource in the Timer DataSource field.

3. Click Save.

4. Restart the Application Server.

   Sample timer database creation files are provided for PointBase and Oracle at install-dir`/lib/install/databases/`.

- Previous: Chapter 7 Connector Resources
- Next: Chapter 9 Configuring Security

- © 2010, Oracle Corporation and/or its affiliates