6.7.1: Application assembly tutorial

During this tutorial, you will assemble a J2EE application .ear file from an EJB JAR file, some Web application components, and a Java application client JAR file. Assembly is a prerequisite to deploying your application on the application server. Put simply, assembly involves identifying the various code artifacts as a single unit (application), and configuring the deployment descriptor of the application.

The application used for this tutorial is a Session bean application, but the assembly steps are similar for a BMP bean application. For information about CMP bean applications, see the Advanced tutorial, which assumes knowledge of this assembly tutorial and others.

Prerequisites

There are no prerequisites for performing this tutorial.

Overview of steps (requires 30 to 50 minutes)

  1. Obtain the tutorial application
  2. Start the Application Assembly Tool
  3. Assemble an EJB module, converting EJB 1.0 JAR to EJB 1.1
  4. Assemble a Web module
  5. Assemble an application client module
  6. Assemble a J2EE application
  7. Generate code for deployment
  8. Exit the Application Assembly Tool
Paths through the tutorial

Obtain the tutorial application

  1. Create a directory named "tutorial" under the path:
    product_installation_root/temp
    
  2. Click here to access the .zip file containing the tutorial application components.
  3. Save the .zip file to
    product_installation_root/temp/tutorial
    
  4. Use your favorite .zip or .jar utility to extract the tutorial.zip content into the tutorial directory.

Tutorial code

Start the Application Assembly Tool

Start the Application Assembly Tool (AAT) by:

  1. Open a system command prompt.
  2. Change directory to product_installation_root/bin
  3. Type assembly.

Starting the assembly tool

Windows NT or 2000 note  If using Windows NT or 2000, and you do not see the graphical interface of the tool right away, check for the minimized tool on the Task Bar.

Assemble an EJB module, converting EJB 1.0 JAR to EJB 1.1

  1. Click Cancel at the Welcome to Application Assembly Tool panel.
  2. Load the EJB jar file into the tool:
    1. Click File -> Open.
    2. Navigate to the SimpleSessionEjb10.jar and select open.
    3. Click OK at the "... please specify the dependent classpath ..." dialog.
  3. [Optional] Edit the deployment descriptor.
    1. Select the jar (the top entry in the assembly tool tree view) and click it to display its properties.
    2. Enter the following:
      1. Display Name: EJB11
    3. Click Apply
  4. Save your changes using File->Save As. Save the file as Ejb11.jar in the path:
    product_installation_root/temp/tutorial/assembly/Ejb11.jar

    Saving the EJB module

You now have a view of the EJB module in the Application Assembly Tool tree view.

EJB module

Assemble a Web Module

  1. Create a new .war file by clicking File -> Wizards -> Create Web Module Wizard.
  2. On the Specifying Web Module Properties panel, enter the following:
    1. Display Name: SimpleSessionWar
    2. File Name: simpleSession.war

      Specifying Web Module Properties

    3. Click Next.
  3. Click Add Class Files... on the Adding Files panel:
    1. Select Browse
    2. Navigate to the servlet.jar file, highlight the file and click Select.
    3. Select the com folder (in the right hand pane).

      Selecting the com folder

    4. Click Add to display the files (in the com folder) in the lower part of the dialog.

      After clicking add button

    5. Click OK.
    6. Click Next.
  4. Click Next on the Specifying Optional Web Module Properties settings panel.
  5. Click Next on the Choosing Web Module Icons settings panel.
  6. Click New... on the Adding Web Components panel to start the Create Web Component Wizard:
    1. On the Specifying Web Component Properties panel:
      1. Enter the Component Name: SimpleServlet

        Specifying Web Component Properties

    2. Select Next.
    3. On the Specifying Web Component Type panel:
      1. Set the Component Type to Servlet.
      2. Click Browse.
      3. Expand the tree view as far as it will go and select servlets.
      4. Select SimpleSessionServlet.class in the right pane.

        Selecting SimpleSessionServlet.class

      5. Click OK.

        Web component has been specified

      6. Click Next
    4. Click Next on the Choosing Web Components Icon panel.
    5. Click Next on the Adding Security Role References panel.
    6. Click Finish on the Adding Initialization Parameters panel. This will return you to the Create Web Module wizard.

      Back to Create Web Module wizard

    7. Click Next.
  7. Click Next on the Adding Security Roles panel.
  8. Click Add on the Adding Servlet Mappings panel.
    1. Specify a URL Pattern: /SimpleSession
    2. Ensure that SimpleServlet is selected as the Servlet.

      Add Servlet Mappings dialog

    3. Click OK.

      Verify that the mapping was added

    4. Click Next.
  9. Click Next at the Adding Resource References panel.
  10. Click Next at the Adding Context Parameters panel.
  11. Click Next at the Adding Error Pages panel.
  12. Click Next at the Adding MIME Mappings panel.
  13. Click Next at the Adding Tag Libraries panel.
  14. Click Next at the Adding Welcome Files panel.
  15. Click Add at the Adding EJB References panel:
    1. Enter the following:
    2. Ensure Session is selected as the Type.

      Adding EJB References panel

    3. Click OK.

      Ready to finish the wizard

  16. Click Finish. The Web module is displayed in the assembly tool interface.

    Web module displayed in tree view

  17. Save the .war file using File -> Save As. Name the file simpleSession.war.

    Save dialog

Assemble an application client module

  1. Create a new application client using File -> Wizards -> Create Application Client Wizard.
  2. On the Specifying Application Client Module Properties panel, enter the following:
    1. Display Name: SimpleSessionClient
    2. File Name: simpleApp.jar
    3. Click Next.
  3. Click Add... on the Adding Files panel.
    1. Select Browse.
    2. Navigate to the client.jar file, highlight the file and click Select.
    3. Select the com folder (in the right hand pane).
    4. Click Add.

      After adding the files

    5. Click OK.
    6. Click Next.
  4. On the Specifying Additional Application Client Modules Properties panel:
    1. Enter Ejb11.jar for Classpath.
    2. Select Browse next to Main Class field.
    3. Expand the tree view in the left pane as far as it goes and select clients.
    4. Select SimpleSessionClient.class in the right panel.

      Selecting the class file

    5. Click OK.

      Module has been specified

    6. Click Next.
  5. Click Next on the Choosing Application Client ModulesIcons panel.
  6. Clcik Add on the Adding EJB References panel.
    1. Enter the following:
    2. Add EJB References panel

    3. Click OK.
    4. Verify that your EJB reference is displayed in the EJB References list.
  7. Click Next.
  8. Click Next on the Adding Resource References panel.
  9. Click the Finish on the Specifying Environment Entries panel. The application client module is displayed in the Application Assembly Tool.

    Client module is now displayed

  10. Save the application client jar file by clicking File -> Save As. Name it simpleApp.jar.

Assemble a J2EE application

  1. Using AAT, create an .ear by clicking File -> Wizards -> Create Application Wizard.

    Selecting the wizard

  2. On the Specifying Application Properties panel:
    1. Enter the following:
    2. Click Next
  3. Click Next on the Adding Supplementary Files panel.
  4. Click Next on the Choosing Application Icons panel.
  5. Click Add... on the Adding EJB Modules panel.
    1. Navigate to your Ejb11.jar file, highlight the file and click Open.
    2. Click OK on the resulting Confirm values dialog.

      Confirm values dialog

      The EJB module is now listed on the Adding EJB Modules panel.

      EJB module is displayed

    3. Click Next.
  6. Click Add... on the Adding Web Modules panel.
    1. Navigate to your simpleSession.war file, highlight the file and click Open.
    2. In the resulting dialog, enter a Context Root: /gettingstarted3

      Confirm values dialog

    3. Click OK.

      The Web module is now listed on the Adding Web Modules panel.

      Web module is displayed

    4. Click Next.
  7. Click Add... on the Adding Application Client Modules panel.
    1. Navigate to your simpleApp.jar file, highlight the file and click Open.
    2. Click OK on the resulting dialog.

      The application client module is now listed on the Adding Application Client Modules file.

      Application client module is displayed

    3. Click Next.
  8. Click Finish on the Adding Security Roles panel.

    The application is now displayed in the Application Assembly Tool.

    Application is now displayed

  9. Bind the EJB and references to it:
    1. In the assembly tool tree view, expand EJB Modules -> EJB11 -> Session Beans -> com_ibm...ejbs_SimpleSession.
    2. Click it to display its properties.

      Selecting the enterprise bean

    3. Select the Bindings tab.

      Bindings tabbed page

    4. Replace the existing text string with gs/hello as the global JNDI name of the session bean.

      After replacing the value


    5. Although this example uses a short name for the session bean, consider using longer names in actual practice. A long name will help ensure that the name is unique in the global name space. An example of a suitable long name is:

      com/ibm/websphere/gettingstarted/ejbs/SimpleSessionHome
      
    6. Click Apply.
  10. Bind the EJB reference (java:comp/env/ejb/ABean) to the global JNDI name of the bean:
    1. Expand Web Modules -> SimpleSessionWar.
    2. Select EJB References.
    3. Select in the right pane the particular reference called ejb/ABean.

      Selecting the enterprise bean

    4. Select the Bindings tab.
    5. Replace the existing text string with gs/hello. This is the JNDI Name that you assigned to the enterprise bean in an earlier step.
    6. Click Apply.
  11. Bind the EJB reference:
    1. Expand Application Clients -> SimpleSessionClient.
    2. Select EJB References.
    3. Select in the right pane the particular reference to your session bean: ejb/SimpleSession
    4. Select the Bindings tab.
    5. Replace the existing text string with gs/hello.   This is the JNDI Name that you assigned to the enterprise bean in an earlier step.

      Changing the JNDI Name

    6. Click Apply.
  12. Save the .ear file by clicking File -> Save As. Name it simpleSession.ear.

    Saving the file

Generate code for deployment

  1. Right-click the .ear file by selecting the top entry in the tree view of the assembly tool.
  2. Select Generate Code for Deployment.

    Generate code for deployment

  3. Select appropriate Database Type.
  4. Click Generate Now.

    Generate Now option

  5. When deployment is complete, close this window.

  Another way to generate code for deployment is to use the Deployment Tool directly. The Application Assembly Tool calls the command line Deployment Tool for you when you use the Generate Now button and accompanying dialog.

Exit the Application Assembly Tool

Exit the assembly tool using the File -> Exit option.

What's next?

Now that you have your application assembled, you can deploy it on the application server, which includes "installing" it. The next steps are outlined by the Application deployment tutorial.