Assemble the application: Assemble the application into an Enterprise Archive file

A J2EE application is represented by and packaged in an enterprise archive (EAR) file. You must assemble your EJB module and your Web module into an EAR file, which you can then install into a WebSphere application server instance. Use the application assembly tool to package your EJB and Web modules into an EAR file.

  1. Start the application assembly tool. On your workstation, select Start --> Programs -> IBM Websphere -> Application Server v5.0 -> Application Assembly Tool.

    Note: If you already have the application assembly tool open, select the File -> New -> Application menu item.

  2. The Welcome to the Application Assembly Tool window is displayed. On the New tab, click Application, and click OK.

    The application assembly tool uses a navigation bar to access various parts of the interface. The EAR file has a default name and directory structure and contains general EAR file information.

  3. Add general EAR file information.

    • On the General tab, specify HitCount in the Display name field.
    • On the Bindings tab, specify HitCount in the Enterprise application name field.
    • Click Apply.

  4. Add the files needed in the EAR file.

    • In the navigation bar, right-click Files, and click Add Files.
    • Click Browse, and navigate to Increment.jar.

      Note: The file resides in the hcsample folder you created on your iSeries server.

    • Select Increment.jar, and click Select.
    • Click Add to add the entire contents of the Increment.jar file to the EAR file.
    • Click OK.
    • Right-click Files, and click Add Files.
    • Click Browse, and navigate to HitCount.war.

      Note: The file resides in the hcsample folder you created on your iSeries server.

    • Select HitCount.war, and click Select.
    • Click Add to add the entire contents of the HitCount.war file to the EAR file.
    • Click OK.

  5. Import the EJB module you created into the EAR file.

    • In the navigation bar, right-click EJB Modules, and click Import.
    • Navigate to Increment.jar, and click Open.
    • Click OK in the Confirm Values window that appears.
    • Expand EJB Modules, expand Increment, and select Entity Beans.
    • On the CMP Resource Bindings tab, make sure that Per Resource is selected in the Resource authentication field.

  6. Import the Web module you created into the EAR file.

    • In the navigation bar, right-click Web Modules, and click Import.
    • Select HitCount.war, and click Open.
    • On the Confirm Values window, type /hc in the Context root field. The context root value becomes part of the URL that is used to access the application once it has been assembled and deployed. For example: http://your.server.name:port/hc/hitcount.
    • Click OK.

  7. Save your EAR file.

    • Select the File -> Save menu item to save your EAR file in the hcsample folder.
    • Save your EAR file as HitCount.ear.
    • Click OK.

  8. Optionally, you can configure security on your EJB module so that all authenticated users are authorized to the enterprise bean's methods.

    • In the navigation bar, right-click Security Roles, and click New.
    • On the General tab, specify ALL Role in the Name field.
    • Optionally, you can specify a description in the Description field.
    • On the Bindings tab, click Add next to the Special subjects: Name field.
    • Select AllAuthenticatedUsers, and click OK.
    • On the Bindings tab, click OK to save your changes.
    • In the navigation bar, expand Entity Beans, expand Incrementejb, right-click Security Roles, and click New.
    • On the General tab, specify All Role in the Name field.
    • Optionally, you can type a description in the Description field.
    • Click OK.
    • In the navigation bar, right-click Method Permissions, and click New.
    • Optionally, you can type a name in the Method permission name field and a description in the Description field.
    • Next to the Methods field, click Add.
    • Expand Increment.jar, and select Increment(*).
    • Click OK.
    • Next to the Role field, click Add.
    • Select All Role, and click OK.
    • On the General tab, click OK to save your changes.
    • Click Save to save the HitCount.ear file with the updated security information.

  9. Optionally, you can configure security on your Web module so that all authenticated users are authorized to the HitCount servlet's HTTP methods (GET and POST).

    • In the navigation bar, select Web module
    • On the Advanced tab, check Login configuration.
    • Select Basic for the Authentication method.
    • Click Apply.
    • In the navigation bar, expand Web module, expand HitCount, right-click Security Roles, and click New.
    • On the General tab, specify All Role in the Name field.
    • Optionally, you can specify a description in the Description field.
    • Click OK.
    • In the navigation bar, expand Web module, expand HitCount, right-click Security Constraints, and click New.
    • Click Add, and select All Role.
    • Click OK.
    • Optionally, you can specify a name and description in Security constraint name and Description fields on the General tab.
    • Click OK.
    • In the navigation bar, expand Security Constraints, and expand the security constraint you created in the previous step.
    • Right-click Web Resource Collection, and select New.
    • In the Web Resource Name field, specify HitCount Servlet.
    • Next to the HTTP methods:HTTP method field, click Add.
    • Select GET, and click Apply.
    • Select POST, and click OK.
    • On the General tab, click OK to save your changes.

  10. Generate code for deployment to a WebSphere Application Server instance.

    • Select the File -> Generate code for deployment... menu item.
    • Take all of the default values except for the Database type field.
    • In the Database type field, select DB2UDBISERIES from the drop-down list.
    • Click Generate now.

    The tool generates a file called Deployed_HitCount.ear, which you use in the next steps.

  11. Once the deployed code is generated, click Close.

Continue Next Step: Configure the server