Tool Mentor: Assembling J2EE Modules and Applications Using RAD 6.0
This tool mentor describes how assemble J2EE modules and J2EE apllications (WAR, EJB JAR, Client Application JAR, RAR and EAR files) using the RAD modeling environment.
Tool: Rational Application Developer
Relationships
Main Description

Overview

Assembly is the process of combining the components of a J2EE application into packages, either as J2EE Modules (see Guideline: J2EE Module) or as a J2EE Application (see Guideline: J2EE Application), that can be deployed to an application server. These packages are formatted as archive files and must conform to a directory structure and content rules defined by the J2EE Application Assembly and Deployment model.

RAD 6.0 greatly facilitates the assembly process by enforcing the development of application components in a Project which represents either a J2EE module or J2EE application. When you create a project, the tool automatically creates a file directory structure within it that conforms to the J2EE Application Assembly and Deployment model. As components are subsequently created through the product's wizards, they are saved by default in the proper folder within the project. For example, when creating a new JSP file using the New JSP File wizard, the tool stores it by default in the Web project's WebContent folder which is the standard location for Web content source files. In addition, RAD 6.0 also automatically generates all the required J2EE assembly and deployment work products such as the Manifest file and the appropriate Deployment Descriptors. Assembling a J2EE module or application, therefore, simply consists of editing the corresponding deployment descriptor(s) as needed and exporting the project to an archive file. The following steps are performed in this tool mentor:

Edit the project's Deployment Descriptor

  1. To edit an Enterprise Application project's (EAR) deployment descriptor:
    1. In the J2EE perspective's Project Explorer view, expand Enterprise Applications > project_name.
    2. Double-click on Deployment Descriptor: project_name to open the Application Deployment Descriptor editor.
    3. Select the appropriate tab at the bottom of the editor view to edit specific deployment descriptor values.
    4. Save the deployment descriptor file by selecting File > Save from the main menu bar.
  2. To edit a Web project's (WAR) deployment descriptor:
    1. In the J2EE perspective's Project Explorer view, expand Web Modules > project_name.
    2. Double-click on Deployment Descriptor: project_name to open the Web Deployment Descriptor editor.
    3. Select the appropriate tab at the bottom of the editor view to edit specific deployment descriptor values.
    4. Save the deployment descriptor file by selecting File > Save from the main menu bar.
  3. To edit an EJB project's (EJB JAR) deployment descriptor:
    1. In the J2EE perspective's Project Explorer view, expand EJB Modules > project_name.
    2. Double-click on Deployment Descriptor: project_name to open the EJB Deployment Descriptor editor.
    3. Select the appropriate tab at the bottom of the editor view to edit specific deployment descriptor values.
    4. Save the deployment descriptor file by selecting File > Save from the main menu bar.
  4. To edit an Application Client project's (Application Client JAR) deployment descriptor:
    1. In the J2EE perspective's Project Explorer view, expand Application Client Modules > project_name.
    2. Double-click on Deployment Descriptor: project_name to open the Client Deployment Descriptor editor.
    3. Select the appropriate tab at the bottom of the editor view to edit specific deployment descriptor values.
    4. Save the deployment descriptor file by selecting File > Save from the main menu bar.
  5. To edit a Connector project's (RAR) deployment descriptor:
    1. In the J2EE perspective's Project Explorer view, expand Connector Modules > project_name.
    2. Double-click on Deployment Descriptor: project_name to open the XML editor on the ra.xml file.
    3. Edit the XML file to change specific deployment descriptor values.
    4. Save the deployment descriptor file by selecting File > Save from the main menu bar.

Validate the project

Although the tool is setup by default to automatically validate resources when you save them, it is a good idea to manually validate your entire project before exporting it to an archive file (Note that you can override and change which validators are run against your project by right-clicking on it and selecting Properties > Validation).

  1. In the J2EE perspective's Project Explorer view, right-click on the project_name.
  2. Select Run Validation.
  3. After the validation is completed, check the Problems view. If errors are listed, resolve them before proceeding to the next step.

Export the project to an archive file

  1. To export an Enterprise Application project to an EAR file:
    1. In the J2EE perspective's Project Explorer view, right-click on the project_name.
    2. Select Export > EAR file.
    3. In the Export wizard, specify the desired name and location of the EAR file.
    4. Optionally select to:
      • Export source files
      • Overwrite existing file if you are exporting to an existing EAR file and do not want to be warned about overwriting it
      • Include project build paths and meta-data files to preserve the original names of projects included in or referenced by the application project and maintain classpath dependencies. This allows you to later import the EAR into another workspace and have its modules be imported as a binary projects.
    5. Click Finish. The wizard exports the contents of the application project to the specified EAR file.
  2. To export a Web project to a WAR file:
    1. In the J2EE perspective's Project Explorer view, right-click on the project_name.
    2. Select Export > WAR file.
    3. In the Export wizard, specify the desired name and location of the WAR file.
    4. Optionally select to:
      • Export source files
      • Overwrite existing file if you are exporting to an existing WAR file and do not want to be warned about overwriting it
    5. Click Finish. The wizard exports the contents of the web project to the specified WAR file.
  3. To export an EJB project to an EJB JAR file:
    1. In the J2EE perspective's Project Explorer view, right-click on the project_name.
    2. Select Export > EJB JAR file.
    3. In the Export wizard, specify the desired name and location of the JAR file.
    4. Optionally select to:
      • Export source files
      • Overwrite existing file if you are exporting to an existing JAR file and do not want to be warned about overwriting it
    5. Click Finish. The wizard exports the contents of the EJB project to the specified JAR file.
  4. To export an Application Client project to an Application Client JAR file:
    1. In the J2EE perspective's Project Explorer view, right-click on the project_name.
    2. Select Export > App Client JAR file.
    3. In the Export wizard, specify the desired name and location of the JAR file.
    4. Optionally select to:
      • Export source files
      • Overwrite existing file if you are exporting to an existing JAR file and do not want to be warned about overwriting it
    5. Click Finish. The wizard exports the contents of the Application Client project to the specified JAR file.
  5. To export a Connector project to a RAR file:
    1. In the J2EE perspective's Project Explorer view, right-click on the project_name.
    2. Select Export >RAR file.
    3. In the Export wizard, specify the desired name and location of the RAR file.
    4. Optionally select to:
      • Export source files
      • Overwrite existing file if you are exporting to an existing RAR file and do not want to be warned about overwriting it
    5. Click Finish. The wizard exports the contents of the Connector project to the specified RAR file.