Tutorials > Program model > Modify an existing controller command

< Previous


Deploy MyOrderItemAddCmdImpl

In this step, we will deploy the modified business logic to a target WebSphere Commerce Server.

  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 will overwrite any existing WebSphereCommerceServerExtensionsLogic.jar file on the target WebSphere Commerce Server. Before proceeding, ensure all previous customizations made to this on the remote WebSphere Commerce Server are included in the file that you export from Rational Application Developer.


Procedure

  1. Create 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, we will notice that you include previously customized code in your JAR file. For example, if you have completed the Tutorial: Creating new business logic, we will notice that when you create the JAR file to deploy the MyOrderItemAddCmdImpl class, we will include the previously created MyNewControllerCmd and other classes.

    To create the JAR file that contains the MyOrderItemAddCmdImpl class, perform the following steps on the development machine:

    1. Create a directory on the local file system called drive:\ExportTemp2.

    2. Open the WebSphere Commerce development environment Project Navigator view.

    3. From the WebSphereCommerceServerExtensionsLogic project's pop-up menu, select Export.

    4. In the Export wizard:

      1. Select 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 example:

        • .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. Note that the JAR file name must be WebSphereCommerceServerExtensionsLogic.jar.

      7. Click Finish.

  2. Export the message properties file

    In this section, we will export the properties file that contains the text for the new message,...

    1. In the Project Navigator view, expand the Stores folder.

    2. From the WebContent folder's pop-up menu, select Export.

    3. In the Export wizard:

      1. 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 will be placed. This directory can be the same directory to which you exported the command JAR file, drive:\ExportTemp2

      6. Click Finish.

  3. Transfer assets to the target WebSphere Commerce Server

    In this step, we will create a temporary directory on the target WebSphere Commerce Server and then copy the MyOrderItemAddCmdImpl assets into this directory. This is an optional step, since the WebSphere Application Server administration console can deploy files to your target server from the local development machine.

    To copy the files from the development machine to the target WebSphere Commerce Server:

    1. On the target WebSphere Commerce Server, create a temporary directory called drive:\ImportTemp2.

    2. Determine how we will copy the files from one computer to another. You can do this 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. Stop the 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://host:portnumber/ibm/console

      ...where host is the name of the target machine, and portnumber you chose at install time. The default port number is 9060.

    2. Click Applications > Enterprise Applications to see a list of installed applications.

    3. Select the WebSphere Commerce application, for example WC_demo, and click Stop.

  5. Update the database on the target WebSphere Commerce Server

    In this step, we will modify the command registry so that it will use the new MyOrderItemAddCmdImpl implementation class.

    Register MyOrderItemAddCmdImpl:

    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 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 used by the target WebSphere Commerce Server

      dbuser

      is the database user

      dbpassword

      is the database password

    6. Click the Execute icon.

    Register MyOrderItemAddCmdImpl:

    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 to use.).

    2. In the User Name field, enter the Oracle user name.

    3. In the Password field, enter the Oracle password.

    4. In the Host String field, enter the 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 the 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 desired:

    1. In the WebSphere Application Server administrative console, click Applications > Enterprise Applications to see a list of installed applications.

    2. Select the WebSphere Commerce application, for example WC_demo, and click Export.

    3. Follow the wizard and save the EAR file in a backup directory. If the EAR file is large in size, this action might take some time.

  7. Update the command JAR file on the target WebSphere Commerce Server

    In this step we will update the target WebSphere Commerce Server to use the JAR file that contains the new MyOrderItemAddCmdImpl,...

    1. In the WebSphere Application Server administrative console, select your application name, for example WC_demo, and click Update.

    2. Select Single File and specify the path to drive:\ImportTemp\WebSphereCommerceServerExtensionsLogic.jar.

    3. In the Relative path to file field, enter WebSphereCommerceServerExtensionsLogic.jar.

    4. Click Next.

    5. Click OK.

    6. 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 choose Single Module instead of Single File.

  8. Update the MyNewErrorMessages.properties file on the target WebSphere Commerce Server

    In this step, we will 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 Single File.

    3. In the Relative path to file field, enter Stores.war\WEB-INF\classes\MyNewErrorMessages.properties.

    4. In the Upload the new or replacement files section specify the path to 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 the changes to the master configuration. All the 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.

    : 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 will result in fewer updates.

  9. Stop and start the WebSphere Application Server

    You must stop and start the WebSphere Application Server to pick up the changes you deployed.

    To stop and start the server:

    1. At a command prompt, navigate to WC_PROFILE\bin.

    2. Stop the WebSphere Application Server. For example, on the Windows operating system, enter stopServer server1. The server has stopped successfully 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: Server server1 open for e-business; process id is 3740.

    4. Navigate to WC_PROFILE\logs\server1.

    5. Examine the SystemOut.log file. Ensure 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

< Previous


+

Search Tips   |   Advanced Search