Deploying Enterprise Beans in Sun's J2EE Reference Implementation


by jGuru

[Help | API Docs | Short Course| Exercises]

This exercise takes you through the process of deploying the MusicCD entity bean and Inventory session bean into the J2EE™ Reference Implementation container. Deploying is usually a major task in an of itself, and it is always application-server specific. If you are using an application server other than J2EE RI, you should consult that server's documentation for the details of how to deploy your beans. You will need to have the MusicCD and Inventory beans deployed for the subsequent exercises.

Prerequisites

Skeleton Code

Tasks


  1. Save the two jar files from the skeleton code section above into your working directory. You should execute the next step from that working directory.

  2. Start the deploytool utility. This runs an application for deploying enterprise beans into a running J2EE RI server.

  3. In deploytool, select "File/New Application..." to create a new application called "MusicStore" saved in a file called "MusicStore.ear".

  4. Select the MusicStore application from the list of deployed applications on the left-hand side of the deploytool GUI. Select "File/Add EJB JAR to Application..." and use the dialog box to open MusicCD.jar which is provided as as the skeleton code for this exercise.

  5. Follow the same procedure to add the Inventory.jar to the application.

  6. With the MusicStore application selected, choose the "JNDI" panel from the main portion of the deploytool window. Fill in the JNDI names for each component as shown:

    MusicCDBean MusicCDBean ejb/MusicCD
    InventoryBean InventoryBean ejb/Inventory
    InventoryBean ejb/MusicCD ejb/MusicCD

  7. Now set up the database mapping for the MusicCD entity bean. You will have to select the "MusicCDBean" component from the left-hand window. Then select the "Entity" tab in the main window and press the "Deployment Settings" button to get the input dialog box. Set the database JNDI name to "jdbc/MusicStore" in this dialog, uncheck the boxes "Create table on deploy" and "Delete table on deploy", then press the "Generate SQL now" button.

  8. The MusicStoreDB that you set up in the previous exercise uses a table called "MusicCD" to store the MusicCD beans. The SQL commands that the J2EE RI automatically generates does not use this exact table name, so you need to select each of the lifecycle methods and edit the SQL being generated for each to change them to operate on the MusicCD table.

  9. In deploytool, select "Tools/Deploy Application..." from the menu. Check the box to "Return Client Jar", otherwise just accept all the defaults and step through the wizard. Select the "Finish" button at the end.

  10. You should see MusicStore application show up in the lower section of the deploytool screen in the panel labeled "Server Applications". You have successfully deployed your beans!.

Where help exists, the task numbers above are linked to the step-by-step help page.

Solution Source

When you have sucessfully deployed the MusicStore application, your deploytool screen should look something like this:

Demonstration

There is no expected behavior for this exercise, outside of the screen shots displayed in the help for each task.

Next Exercise

Exercises

Short Course

Copyright 1996-2000 jGuru.com. All Rights Reserved.