Deploying MyOrderItemAddCmdImpl

In this lesson, you deploy the modified business logic to a target WebSphere Commerce Server.

Introduced in Feature Pack 3Note: This lesson demonstrates how to manually deploy your customized assets. You can however use the WebSphere Commerce Build and Deployment tool to deploy you assets instead. For more information, see Tutorial: Using the WebSphere Commerce Build and Deployment tool.

About this task

  1. Create the JAR file that contains the command logic and error classes.
  2. Export the error message properties file.
  3. Transfer the assets to the target WebSphere Commerce Server.
  4. Update the command registry on the target WebSphere Commerce Server.
  5. Validate the new logic on the target WebSphere Commerce Server.

The following steps overwrite any existing WebSphereCommerceServerExtensionsLogic.jar file on the target WebSphere Commerce Server. Ensure that all previous customizations that are made to this JAR file on the remote WebSphere Commerce Server are included in the file that you export from Rational Application Developer.

  • Java files in the WebSphereCommerceServerExtensionsLogic.jar file.
    • com\ibm\commerce\sample\databeans\OrderGiftDataBean.java
    • com\ibm\commerce\sample\commands\MyExtOrderProcessCmdImpl.java
  • store assets
    • ordergift.properties

Procedure

  1. Creating the command JAR file:
    Tip: Following the WebSphere Commerce code customization strategy, customized commands and data beans are placed in the WebSphereCommerceServerExtensionsLogic project. As a result, when it comes time to deploy customized code, you notice that you include previously customized code in your JAR file. For example, if you completed the following task, you can notice that when you create the JAR file to deploy the MyOrderItemAddCmdImpl class, you include the previously created MyNewControllerCmd and other classes.
    To create the JAR file that contains the MyOrderItemAddCmdImpl class, perform the following steps on your development machine:
    1. Create a directory on your local file system called drive:\ExportTemp2.
    2. Open the WebSphere Commerce development environment Project Navigator view.
    3. Right click WebSphereCommerceServerExtensionsLogic and select Export.
    4. In the export wizard:
      1. Expand the Java folder. Select the JAR file and click Next.
      2. The left pane under Select the resources to export is prepopulated with the name of the project. Leave this value as is.
      3. In the right pane, ensure that resources that begin with a period are not selected. For instance:
        • .classpath
        • .project
        • .serverPreference
        • .runtime
      4. Ensure that Export generated class files and resources is selected.
      5. Do not select Export Java source files and resources.
      6. In the Select the export destination field, enter the fully qualified JAR file name to use. In this case, enter drive:\ExportTemp2\WebSphereCommerceServerExtensionsLogic.jar. The JAR file name must be WebSphereCommerceServerExtensionsLogic.jar.
      7. Click Finish.
  2. Export the properties file that contains the text for the new message:
    1. In the Project Navigator view, expand the Stores folder.
    2. Right-click the WebContent folder and select Export.
    3. In the export wizard:
      1. Expand the General folder. Select File system and click Next.
      2. Click Deselect All.
      3. Select to export the following resource: Web Content\WEB-INF\classes\MyNewErrorMessages.properties
      4. Select Create directory structure for files.
      5. In the Directory field, enter a temporary directory into which these resources are placed. This directory can be the same directory to which you exported the command JAR file, drive:\ExportTemp2
      6. Click Finish.
  3. Transferring assets to the target WebSphere Commerce Server. In this step, you create a temporary directory on the target WebSphere Commerce Server and then copy your MyOrderItemAddCmdImpl assets into this directory. This step is an optional step, since the WebSphere Application Server administration console can deploy files to your target server from your local development machine. To copy the files from your development machine to your target WebSphere Commerce Server:
    1. On the target WebSphere Commerce Server, create a temporary directory called drive:\ImportTemp2.
    2. Determine how you going to copy your files from one computer to another. You can do this copy by mapping a drive on the target WebSphere Commerce Server to the development machine, or by using an FTP application, if you have that configured.
    3. From the development machine, copy the contents of drive:\ExportTemp2 into drive:\ImportTemp2 on the target WebSphere Commerce Server.
  4. To stop your target WebSphere Commerce application, open the WebSphere Application Server administration console and stop the WebSphere Commerce application:
    1. Open the WebSphere Application Server administrative console by entering the following URL in a web browser: http://your_fully_qualified_server_name:portnumber/ibm/console , where your_fully_qualified_server_name is the name of your target machine, and portnumber you chose at installation time. The default port number is 9060.
    2. Click Applications > Application types > WebSphere enterprise applications to see a list of installed applications.
    3. Select your WebSphere Commerce application.
      For example, WC_demo, and click Stop.
  5. Updating the database on the target WebSphere Commerce Server. In this step, you modify the command registry so that it uses your new MyOrderItemAddCmdImpl implementation class.
    DB2Register MyOrderItemAddCmdImpl:
    DB2
    1. Open the DB2 Command Editor (Start > Programs > IBM DB2 > Command Line Tools > Command Editor).
    2. From the Tools menu, select Tools Settings.
    3. Select the Use statement termination character check box and ensure the character that is specified is a semicolon (;).
    4. Close the Tools Settings.
    5. With the Script tab selected, create the required entry in the CMDREG table, by entering the following information in the script window:
      
      connect to targetDB user dbuser using dbpassword;
      update CMDREG
      set CLASSNAME='com.ibm.commerce.sample.commands.MyOrderItemAddCmdImpl'
      WHERE INTERFACENAME=
      'com.ibm.commerce.orderitems.commands.OrderItemAddCmd'
      and storeent_Id=0;
      
      Where:
      targetDB
      is the name of the database that is used by your target WebSphere Commerce Server.
      dbuser
      is the database user.
      dbpassword
      is the database password.
    6. Click the Execute icon.
    OracleRegister MyOrderItemAddCmdImpl:
    Oracle
    1. Open the Oracle SQL Plus command window (Start > Programs > Oracle - oracle_home > Application Development > SQL Plus, where oracle_home is the name of the oracle home you want to use).
    2. In the User Name field, enter your Oracle user name.
    3. In the Password field, enter your Oracle password.
    4. In the Host String field, enter your connect string.
    5. In the SQL Plus window, enter the following SQL statement:
      
      update CMDREG
      set CLASSNAME='com.ibm.commerce.sample.commands.MyOrderItemAddCmdImpl'
      WHERE INTERFACENAME=
      'com.ibm.commerce.orderitems.commands.OrderItemAddCmd'
      and storeent_Id=0;
      
      Press Enter to run the SQL statement.
    6. Enter the following statement to commit your database changes:
      
      commit;
      
      Press Enter to run the SQL statement.
  6. Export a backup copy the EAR
    Tip: Export a backup copy of the EAR, so that you can revert to the old version in the future if needed:
    1. In the WebSphere Application Server administrative console, click Applications > Application types > WebSphere enterprise applications to see a list of installed applications.
    2. Select your WebSphere Commerce application, for example WC_demo, and click Export.
    3. Follow the wizard and save your EAR file in a backup directory. If the EAR file is large, this action might take some time.
  7. Updating the command JAR file on the target WebSphere Commerce Server. In this step, you update the target WebSphere Commerce Server to use the JAR file that contains the new MyOrderItemAddCmdImpl, as follows:
    1. In the WebSphere Application Server administrative console, select your application name.
      For example, WC_demo, and click Update.
    2. Select Replace or add a single file.
    3. In the Specify the path beginning with the installed application archive file to the file to be replaced or added field, enter WebSphereCommerceServerExtensionsLogic.jar.
    4. In the Specify the path to the file box, specify the path to your copied file, such as drive:\ImportTemp\WebSphereCommerceServerExtensionsLogic.jar.
    5. Click Next.
    6. Click OK.
    7. When the update completes click Manage Applications. Leave the WebSphere Application Server administrative console open.

    If you see a class cast exception, you likely chose the wrong type of update, for example, you chose Single Module instead of Single File.

  8. Updating the MyNewErrorMessages.properties file on the target WebSphere Commerce Server. Add the JSP, JSPF, and properties files to the application:
    1. In the WebSphere Application Server administrative console, select your application name.
      For example, WC_demo, and click Update.
    2. Select Replace or add a single File.
    3. In theSpecify the path beginning with the installed application archive file to the file to be replaced or added field, enter Stores.war\WEB-INF\classes\MyNewErrorMessages.properties.
    4. In the Specify the path to the file box, specify the path to your copied file: drive:\ImportTemp\MyNewErrorMessages.properties.
    5. Click Next.
    6. Click OK.
    7. When the update completes successfully, click Save to Master Configuration.
    8. On the Enterprise Applications screen, click Save to save your changes to the master configuration. All your changes are saved, including updating the store assets, command, and data bean file and the EJB JAR file.
    9. Close the WebSphere Application Server administration console.
    Note: : It is possible to update both the properties file and the WebSphereCommerceServerExtensionsLogic.jar in one partial application update. In this tutorial, the updates are separated for clarity, however in a production environment, combining the updates result in fewer updates.
  9. You must stop and start your WebSphere Application Server before you can view the changes that you deployed. To stop and start your server.
    1. At a command prompt, navigate to WC_profiledir\bin.
    2. Stop the WebSphere Application Server.
      For example, on the Windows operating system, enter stopServer server1. The server is successfully stopped when you see the message: Server server1 stop completed.
    3. Start the WebSphere Application Server.
      For example, on the Windows operating system, enter startServer server1. Wait until you see the message similar to the following message: Server server1 open for e-business; process id is 3740.
    4. Go to the WC_profiledir\logs\server1 directory.
    5. Examine the SystemOut.log file. Ensure that the server started successfully without errors.
  10. Verify the MyOrderItemAddCmdImpl logic on the target WebSphere Commerce Server.
    Verify that the code is working after deployment by following the steps in Test the MyOrderItemAddCmdImpl command