How do I prepare and deploy EJB applications?
How do I prepare and deploy EJB applications?
EJB applications include EJB components like session beans, entity beans and MDB’s. EJB applications are deployed on Pramati EJB Container. Pramati Server supports deployment of both EJB 1.1 and 2.0 beans.
If EJB applications contain stateless, stateful, and Bean Managed Persistence (BMP) beans compliant to EJB 1.1 standards, they are automatically migrated to EJB 2.1 at the time of deployment.
This section discusses how to implement, assemble, deploy, and invoke EJB applications that are deployed on Pramati Server.
How do I package EJB applications?
EJB applications can be packaged as .jar or .ear files.
How do I deploy EJB applications?
Deploying EJB applications refers to making beans available to clients. EJB applications can be deployed on Pramati Server as either standard .jar or .ear files. To get an application to a ready-to-deploy state, you need to resolve EJB information with regard to Server environment such as resource references, resource environment references, concurrency, and security role references.
The bean properties node facilitates specifying the properties of each bean. To set the bean properties using the Deploy Tool, click the bean properties node in the node tree to set the properties for each bean. This opens a panel on the right, which displays a table listing all the beans in the application with their properties.
Depending on the selected application, the attributes that can be set here are general properties, EJBs, resources, resource environment, sessions, bean pools, run as security information, JNDI name, and MDB destinations.
The General properties panel appears by default when you click the Bean Properties node. The panel displays the following attributes:
- JAR: The name of the Java archive is displayed in this field. This field is not editable.
- Bean: The Bean name is displayed here. This field is not editable.
- JNDI Names: This field displays the JNDI names for the beans. JNDI names should be unique across the Server. The deploy tool provides JNDI names to the beans by automatically retrieving the EJB names from the file,
ejb-jar.xml.
- If the EJB name is already bound, the name
ejb-name@jarname is provided, where ejb-name represents the name of the Bean, and jar name represents the name of the JAR. In case the above name is also bound, the names provided are ejb-name@jarname1, ejb-name@jarname2, ejb-name@jarname3 and so on such that the JNDI name provided is always unique. JNDI name can be modified by entering the value in the field.
- Beans having remote interfaces are the only beans that have JNDI names.
- Beans having local interfaces, have a local bean name and no look up can be performed on these. They are accessed using local EJB references.
- The Deploy Tool does not allow a busy local bean name to be used as a JNDI name for other objects, saving the user from confusion. Similarly, a busy JNDI name cannot be used as a local name of a bean. Server uses internal naming conventions for local EJB bindings.
- SSL: Select or deselect the option to set the Secure Sockets Layer protocol as enabled or disabled. The SSL protocol provides authentication and message protection at the transport layer.
- CLB: Select or deselect the option to mark a bean if it is to be deployed in a clustered environment. This facilitates a transparent failover for non-idempotent beans.
Note: No JNDI names are provided for MDBs as they do not have a client view.
This panel is displayed when you click the EJB tab in the Bean Properties node. This panel lists the beans which refer other beans in the container. The attributes provided in this tab are:
- JAR: The name of the Java archive is displayed in this field. This field is not editable.
- Bean: The Bean name is displayed here. This field is not editable.
- Reference Name: This field displays the EJB reference names that are to be mapped to a link name. All the link names and the JNDI names bound on the Server and set in the General tab in the Bean properties node are available for mapping.
- Type: The EJB reference can be set as either remote or local.
- References of type local can refer to the referred bean only through the local interfaces; and both referred and referring bean should be in the same virtual machine. The drop-down list for selecting the link name contains only local bean names available in the server and in the current application.
- References of type remote refer to referred bean only through remote interface and the referring bean can be in a different virtual machine. The drop-down list for selecting link name contains all the bean, and JNDI names in the server as well as current application.
- Link Name: Select from the list of Link Names provided in the drop-down list. This becomes the local EJB name of the referred bean.
Selecting any of the beans row displays the EJB reference type, the interfaces of the bean such as LocalHome or RemoteHome and also an optional description in the panel.
Clicking the Resource tab facilitates mapping of resource references onto the resources defined on the server. In case a new resource is added using the Management Console, it gets added to the running Server.
The attributes in this panel are:
- JAR: The name of the Java archive is displayed in this field. This field is not editable.
- Bean: The Bean name is displayed here. This field is not editable.
- Reference Name: This field displays the resource reference name. It is named as
type and resourcename, where type represents the resource type and resourcename is the name of the resource.
- Resource: The resource type is automatically selected from
ejb-jar.xml. The drop-down list displays the resources only of resource reference type. It includes resources directly bound to the server, and those from the .rars deployed on the Server.
Selecting a row displays the resource type, the resource authorization, and an optional description in the lower half of the panel.
Click the Resource Environment tab in the Bean Properties node. It displays details of an enterprise bean that refers to an administered object. This object is associated to a resource in the bean’s environment.
The panel contains the resource environment reference name, the resource environment reference type expected by the enterprise bean code, the bean name, and the archive which the bean belongs to. For JMS, the resource environment reference can be selected from the types javax.jms.Queue and javax.jms.Topic. The drop-down list displays only the objects of resource environment type.
The deployer can select the value assigned to the bean's resource environment reference.
The Session tab displays the following attributes:
- JAR: The name of the Java archive is displayed in this field. This field is not editable.
- Bean: The Bean name is displayed here. This field is not editable.
- Timeout (min): This field represents the time for which the pool size is kept under observation, and then set for each bean.
After the specified time, if the actual usage of bean instances is below the minimum pool size, the pool size is automatically reduced to the minimum pool size. This provides an optimized use of bean pool.
The Bean Pool tab displays the following attributes:
- JAR: The name of the Java archive is displayed in this field. This field is not editable.
- Bean: The Bean name is displayed here. This field is not editable.
- Max Size: This is the maximum number of bean instances to be retained in the bean pool. The default size is 10.
- Min Size: This is the minimum number of bean instances to be retained in the bean pool. The default size is 0.
- Low Activity Interval (s): Low Activity Interval (LAI) represents the time for which the pool size is kept under observation, and then set for each bean. The object-level caching size and the number of beans that can be maintained in the pool for reuse is determined by the LAI in seconds. After the specified time, if the actual usage of bean instances is below the minimum pool size, the pool size is automatically reduced to the minimum pool size. This provides an optimized use of bean pool.
- Wait Time (s): The wait time in seconds represents the time for which the pool size is kept under observation, and then set for each bean. After the specified time, if the actual usage of bean instances is below the minimum pool size, the pool size is automatically reduced to the minimum pool size. This provides an optimized use of bean pool.
- Use Free Pool: Select or deselect the option to set the free pool usage as enabled or disabled.
All the environment entries that can be accessed from the EJB code are displayed here. An environment entry is scoped to the bean. This means:
- The environment entry cannot be accessed from other enterprise beans at runtime.
- Other enterprise beans can use the same named environment entries without conflict.
The following fields are displayed in the Environment Properties panel:
What is an EJB Environment?
Table 1: EJB Environment properties
| Fields | Description |
| Jar | The Java archive name is displayed here. This field is not editable. |
| Bean | The bean name is displayed in this field. This field is not editable. |
| Entry Name | Name of the environment entry. |
| Type | The Java type of environment entry. |
| Value | The value assigned for the environment entry. This field is editable. |
What is a Web Environment?
Table 2: Web environment properties
| Fields | Description |
| War | The Web archive name is displayed here. This field is not editable. |
| Bean | The bean name is displayed in this field. This field is not editable. |
| Entry Name | Name of the environment entry. |
| Type | Java type of environment entry. |
| Value | The value assigned for the environment entry. This field is editable. |
The Security related views are available only if the selected application contains references to Security.
Click Security node in the Deploy Tool to bring up the Security panel. This enables assigning of realm roles to the security roles defined in the .jars. The available realm roles are obtained from the Security service started by the Server.
The attributes in this panel are:
Table 3: Attributes of Security Role References
| Fields | Description |
| Realm | This specifies the realm name. Select from the available realms in the drop-down list. |
| Module | This displays the JAR name, or the application level role name in the security role. |
| Role Name | This field displays all role names that have been already defined for the application. The management console may be used to define the security roles. |
| Role Link | Select from the role links available in the drop-down list whose value is the name of the security role. |
Note: If there is a problem in obtaining the security service from the Server, check the log and Status window in the Management Console.
What is 'Run As Roles'?
Select the Run As tab in the Bean Properties node. The deployer uses this to map a user to the Run As role for a bean. The panel displays the following attributes:
- JAR: The Java archive names are displayed in the first field. This field is not editable.
- Bean: The bean names are displayed in this field. This field is not editable.
- Run As: This field displays all the run as role names of the bean.
- User: The drop-down list displays all the users of the actual role mapped to role name, corresponding to the run as role names.
Note: This panel appears only if Security Roles have been added.
How do I view deployed EJBs?
All configured server instances on the local machine are displayed under the nodes directory in the server installation directory. This directory also provides references that can be used for viewing deployed applications on these servers.
Deploying a jar or ear on Server creates the following directory structure:
- An archives directory is created at
<install_dir>/server/nodes/<node_name> and contains all the deployed classes and files. Here, node_name is the name of the configured node on which the application has been deployed. Example: c:/pramati_server/nodes/<default>/archives, where default is the name of the configured server.
- The EJB classes deployed on Server are extracted and stored in:
<install_dir>/server/nodes/<node_name>/archives/archive_name/archive_version/classes in the appropriate package hierarchy. Here, node_name is the name of the configured node on which the application has been deployed. The name of the archive deployed is represented by archive_name.
- The classes directory for an application is located under
<install_dir>/server/nodes/<node_name>/archives/archive_name. The client jar required for java clients, for MyApp.ear is stored at classes/MyAppClient.jar.
- A directory for the jar files is created at
<install_dir>/server/nodes/<node_name>/archives/<archive_name>/<jar_name>. It stores the ejb-jar.xml file, and also the queries.props file. Here, node_name is the name of the configured node on which the application has been deployed. The name of the archive deployed is represented by archive_name, and the name of the jar in the application by jar_name.
- The xml files -
application.xml, pramati-j2ee-server.xml, web.xml, ejb-jar.xml, ra.xml, and pramati-or-map.xml are stored at <install_dir>/server/nodes/<node_name>/archives/<archive_name>. Here, node_name is the name of the configured node on which the application has been deployed. The name of the archive deployed is given by archive_name.
Undeploying the application removes the above files from their respective locations.
|