Chapter 4. Common Characteristics of EJB

Table of Contents

4.1. Overview
4.1.1. EJB Types
4.1.2. Deployment Descriptor Configuration by EJB Type
4.2. Configuring EJB
4.2.1. Basic Environment Configuration
4.2.2. Thread Ticket Configuration
4.2.3. External Reference Configuration and Mapping
4.2.4. HTTP Invoke Environment Configuration
4.2.5. JEUS RMI Configuration
4.2.6. EJB Security Configuration
4.3. Monitoring EJB
4.4. Tuning EJB
4.4.1. Thread Ticket Pool Configuration Tuning

This chapter describes the common characteristics of EJBs in JEUS environment.

This chapter does not cover the EJB standard, and only conveys additional information that is required to use EJB in JEUS environment. For information on EJB deployment, refer to "Chapter 3. EJB Module".

This section discusses EJB types and their DD configurations.

The following EJB types are supported in JEUS.

This chapter will describe all the shared characteristics and configurations that apply to all bean types. In the previous list, we have indicated the chapter where you can find additional information about the type.

Note

Entity Bean is replaced by JPA from EJB 3.0. For more information, refer to the "JEUS JPA Guide". Therefore, it is not recommend to use Entity Bean, which is supported for compatibility reasons.

JEUS EJB Deployment Descriptor (hereafter JEUS EJB DD) is a generic XML file named jeus-ejb-dd.xml, and it is placed in the META-INF directory of an EJB JAR file. For information on JEUS EJB DD, refer to "Chapter 3. EJB Module".

The following table offers a summary of all the functions and components that can be configured in JEUS EJB DD ("@" indicates that the entity can be configured using annotation). The items listed on the left column of the table represent the actual configurable XML tags of a JEUS EJB DD. The six columns to the right show whether the component is applicable to each of the EJB types.


The previous table is partitioned as follows:

All the EJB settings are configured in the jeus-ejb-dd.xml file, the JEUS EJB DD file. The parent XML tag is <jeus-bean> regardless of the bean type.

The next section will describe settings applicable to XML parent tags for the five EJB types. Other tags outside the <beanlist> have already been discussed in "Chapter 3. EJB Module". Refer to the latter chapters in this guide for more information on specific XML parent tags (bean type).

Note

For information on clustering settings, refer to "Chapter 6. EJB Clustering".

The following settings are only for JEUS, and are defined in the jeus-ejb-dd.xml file. For more information on this file, refer to "Chapter 3. EJB Module".

  • <ejb-name>

    • It uses the <ejb-name> value from the ejb-jar.xml file, or the "name" value of @Stateless, @Stateful, and @MessageDriven annotations in the implementation class.

  • <export-name>

    • It has to have a unique name to be registered with the global JNDI.

    • If this element is not defined in the DDs, either the mappedName attribute value of @Stateless or @Stateful annotation, or the <mapped-name> value in ejb-jar.xml is applied.

      If none is configured, a Remote Business Interface name is used as the default value. But the default value is applied only when there is one Remote Business interface but no Remote Home Interface or vise versa. Otherwise, the deployment will fail because the JNDI name cannot be determined.

    • The priority is as follows:

      1. <export-name> of jeus-ejb-dd.xml

      2. <mapped-name> of ejb-jar

      3. mappedName of @EJB

      4. Class name (including package name) of remote business interface, the default value

  • <local-export-name>

    • It has to have a unique name within the system to be registered to JNDI.

    • It is applied to the mappedName attribute of @EJB annotation when this element is not configured in DD. If remote business interface exists, '_Local' is attached to this value.

      If neither exists, local business interface name is used as the default value. But the default value is applied only when there is one Local Business interface but no Local Home Interfaces or vise versa. Otherwise, an exception will occur because the JNDI name cannot be found.

    • The priority is as follows:

      1. <local-export-name> of jeus-ejb-dd.xml

      2. If a remote business interface exists, <mapped-name>+ _Local of ejb-jar.xml

        If a remote business interface does not exist, <mapped-name> of ejb-jar.xml

      3. If a remote business interface exists, mappedName + _Local of @EJB

        If a remote business interface does not exist, mappedName of @EJB

      4. Class name (including package name) of local business interface, the default value

  • <export-port>

    • This setting is used when RMI service port needs to be specified explicitly.

    • It is useful when system access is possible only through a certain port because of a firewall. The value of this tag should be same as the firewall's allowed port. If a value is not specified, ports are applied according to the system properties as follows:

      TagDescription
      jeus.ejb.exportPortDetermines export ports of EJBs whose <export-port> is not specified for a specific EJB in jeus-ejb-dd.
      jeus.rmi.usebaseportIf the value is true or false, MS base port or MS base port + 7 is used respectively.
  • <export-iiop>

    • If this setting is activated, it enables the interfaces of the bean to be exported to COS naming server as IIOP stubs and skeletons. This enables all clients, who can access IIOP, to access the bean.

  • <use-access-control>

    • When executing bean methods, this Boolean element determines whether the method execution is monitored by Java SE security manager according to Java EE principal. For more information, refer to the "JEUS Security Guide" and JACC specification. The default value is false.

The following examples show how the previous settings can be applied to the Session Bean classes and DDs. Elements of corresponding annotation and DDs are displayed in bold.



The following figure illustrates the concept of EJB thread ticket pool (hereafter TTP).

If there is a client request, a new RMI thread is assigned to the client request. If the number of assigned threads is greater than the configured maximum value, the request waits for an available thread.


As can be seen from the figure, a thread pool contains thread tickets (hereafter TT). One TT permits one client thread to access the EJB engine. When a client request arrives, one TT is drawn from the TP and assigned to the client. This implies that each client thread will be assigned to one EJB object that will relay the request to an actual EJB instance. An EJB object is thus an object that lives in the EJB engine and manages the connection between an EJB client and an actual EJB instance.

If more client requests arrive than there are TTs in the thread ticket pool, the new requests must wait until a TT is returned to the pool. If the waiting period exceeds 10 minutes, it throws a RemoteException due to a timeout.

TTs are returned to TTP when the client gets disconnected after EJB process terminates (for stateless session bean), or a connection timeout occurs. Each remote-call enabled EJB component contains a TTP. There are also connection and bean pools. Bean pool, instead of TTP, should be configured for MDB.

TT of EJB is configured in the <thread-max> element of the root XML tag of the bean. This value represents the maximum number of allowable threads that can operate in each EJB, in other words, the maximum number of TT. The default value is 100. If the number of client requests in a queue is larger than this value, new requests have to wait until a running job is finished and the TT is returned to the pool. If the waiting period exceeds 10 minutes, it throws a RemoteException due to a timeout.

The following shows how to apply the previous settings to a BMP bean.


External references that the bean uses can be configured through annotation or JNDI export name in jeus-ejb-dd.xml, which is mapped to the reference name used in ejb-jar.xml. In the actual system, all defined external references must be mapped to JNDI export name.

Annotations or all the external references defined in ejb-jar.xml must be mapped to relevant tags in jeus-ejb-dd.xml using the JNDI export-name used in the actual system.

Reference tags of ejb-jar.xml and JEUS EJB DD files are as follows:


Every <env> tag has the following child tags:

TagDescription
<name>Name of env. Same value as the <env-entry-name> defined in the ejb-jar.xml.
<type>Complete Java class name corresponding to the data type of the value. Basic data types use a wrapper class.
<value>Specifies actual value of env.

Other three tags (<ejb-ref>, <res-ref>, and <res-env-ref>) have several <jndi-info> child tags. These tags, in turn, have to set the following child tags to map JNDI export name to reference.

TagDescription
<ref-name>Reference name defined in EJB source code and ejb-jar.xml. <ejb-ref> and <resenv- ref> are equivalent to <ejb-ref> and <resource-env-ref>, respectively, in ejb-jar.xml.
<export-name>Used when an entity or object is exported to JNDI.

Note

<ref-name> and <export-name> tags must be same with the names defined in ejb-jar.xml.

The following is an example of annotation and XML that illustrates how to map external references to JNDI.




In order to set up HTTP invocation on a specific EJB module, <invoke-http> needs to be configured inside the <jeus-bean> element of jeus-ejb-dd.xml. If an EJB engine needs HTTP invocation, add the <invoke-http> tag to the ejb-engine in the jeus-ejb-dd.xml file. (mentioned in "Chapter 2. EJB Engine"). Settings in the domain.xml file will be applied to all the modules, but if the DD of each module contains the <invoke-http> setting, the setting in DD file is used.

The following example configures the HTTP invoke environment properties in jeus-ejb-dd.xml.


<invoke-http> tag has the following two child tags.

TagDescription
<url>

Must enter the URI of the RMI Handler Servlet (jeus.rmi.http.ServletHandler) that is called from the HTTP-RMI stub. Enter only the request path of the Servlet excluding the protocol, IP, and port.

Protocol and IP are assumed to be the same as HTTP and RMI runtime, respectively. This means the Web server and Web engine that received HTTP-RMI request should be on the same machine with the RMI runtime. This way, the RMI runtime address is known to the RMI stub. Web server port should be specified in the following <http-port> element.

<http-port>Specify the port to receive HTTP-RMI requests. The RMI Handler Servlet must be deployed and executed on the Web engine.

This section describes how to configure security for EJB in JEUS. Here security refers to certification and authorization.

The following issues are covered by JEUS EJB security settings.

  • Role assignment of EJB modules

  • EJB run-as Identify setting

The following explains how to configure security settings for each case.

Role Assignment Configuration

The role assignment setting of EJB is mapping developer-defined role of the ejb-jar.xml file with principal and group name of the actual JEUS security domain. Configure this setting in the <role-permission> element inside the <module-info> element of the jeus-ejb-dd.xml file.

The following is an example of configuring a role in XML.


The two necessary child tags are as follows:

TagDescription
<role>Specifies the logical role name defined in the EJB (through annotation or ejb-jar.xml file).
<principal>Specifies actual user name defined in the accounts.xml file. A role name and user name pair defines the mapping between a developer-defined role and JEUS principal. A role can be mapped to multiple user names.

Run-as Identify Configuration

Run-as identity setting provides the actual mapping of developer-defined role name in the <run-as> tag of the ejb-jar.xml file with the actual principal specified in the JEUS security domain configuration (e.g., in the accouts.xml file).

This principal, in general, uses a simple user name. This setting is configured in the <run-as-identity> tag, which is at the same level as the bean configuration in jeus-ejb-dd.xml.

The following is an example of XML setting for run-as identity.


TagDescription
<principal-name>Specifies the user name to map with role in the <run-as> element of the ejbjar.xml file. This user name should be specified in the accounts.xml file.

The following examples show how the role of role-permission and role of run-as are mapped to an actual JEUS user.

Some parts of Java classes and XML are taken from three configuration files (ejb-jar.xml, jeus-ejb-dd.xml, and accounts.xml). The identical parts in these files are highlighted in bold.




The previous example defines two session beans.

  • The first bean (CustomerEJB) has a security role connected to the CUSTOMER role.

  • The second session bean (EmployeeService) defines the <run-as> role as ADMIN. The roles CUSTOMER and ADMIN should be mapped to actual system Principals when EJB is deployed.

The following example shows how the roles, CUSTOMER and ADMIN are mapped to the actual system principal names (customer and peter, respectively).


The following example shows how these users are configured in the accounts.xml file.


The previous example shows definition for the users, customer and peter. These users are connected to the roles, CUSTOMER and ADMIN, of the ejb-jar.xml file through the jeus-ejbdd.xml file.

JEUS does not provide a method to control each EJB included in the EJB module. However, it is possible to monitor each bean through the jeusadmin or WebAdmin. It is recommended to use the WebAdmin.

In the console tool, each EJB information including bean name, export name, and status can be displayed using the application-info command. If an EJB called countermod is deployed, use the following command.

As the result of the previous command, the name and export name of each bean registered to the EJB module are displayed.

[DAS]domain1.adminServer>application-info -server server1 -id countermod -detail
General information about the EJB module [countermod].
==============================================================
+-------------+----------------------------------------------+
| Module Name |              Unique Module Name              |
+-------------+----------------------------------------------+
| countermod  | countermod                                   |
+-------------+----------------------------------------------+
==============================================================

Beans
================================================================================

+-----------+-------------------------+-------------------+--------------------+
| Bean Name |           Type          | Local Export Name | Remote Export Name |
+-----------+-------------------------+-------------------+--------------------+
| Count     | StatelessSessionBean    |                   | Count              |
+-----------+-------------------------+-------------------+--------------------+

================================================================================

The status of each bean in EJB module can be monitored with the following command.

[DAS]domain1.adminServer>application-info -server server1 -id countermod -bean Count
Module name : countermod
Bean name : Count
================================================================================

+---------------+-----------+-------------------+--------------+---------------+
|      Name     |  (Count)  | WaterMark(High:Low| Bound(Upper:L| Time(Max:Min:T|
|               |           |       :Cur)       |    ower)     |     otal)     |
+---------------+-----------+-------------------+--------------+---------------+
| create        | times(0)  |                   |              |               |
+---------------+-----------+-------------------+--------------+---------------+
| comitted      | transactio|                   |              |               |
|               |n(0)       |                   |              |               |
+---------------+-----------+-------------------+--------------+---------------+
| total-remote-t|           |thread(100:100:100)|              |               |
|hread          |           |                   |              |               |
+---------------+-----------+-------------------+--------------+---------------+
| timed-rb      | transactio|                   |              |               |
|               |n(0)       |                   |              |               |
+---------------+-----------+-------------------+--------------+---------------+
| remove        | times(0)  |                   |              |               |
+---------------+-----------+-------------------+--------------+---------------+
| active-bean   |           | bean(0:0:0)       |              |               |
+---------------+-----------+-------------------+--------------+---------------+
| request       | request(0)|                   |              |               |
+---------------+-----------+-------------------+--------------+---------------+
| total-bean    |           | bean(0:0:0)       |              |               |
+---------------+-----------+-------------------+--------------+---------------+
| rolledback    | transactio|                   |              |               |
|               |n(0)       |                   |              |               |
+---------------+-----------+-------------------+--------------+---------------+
| active-thread |           | thread(0:0:0)     |              |               |
+---------------+-----------+-------------------+--------------+---------------+
| MethodReadyCou|           | bean(0:0:0)       |              |               |
|nt             |           |                   |              |               |
+---------------+-----------+-------------------+--------------+---------------+

================================================================================

There are some settings that can be uniformly applied to all EJB types in order to enhance EJB operation performance (or to prevent system resources from being wasted):

There are many tuning tips for each bean type besides the already mentioned basic optimization options. Therefore, look up the corresponding chapter for optimization and tuning method recommended for each EJB type.