Tutorials > Program model > Extend the object model and modifying an existing task command

< Previous | Next >


Deploy the gift message functionality

This section describes how to deploy the new business logic into a store running on a remote WebSphere Commerce Server. You must have created a store based on the consumer direct sample store on the remote WebSphere Commerce Server before starting these deployment steps. Within that store, be able to complete a purchase.

The deployment process includes steps that are performed on the development machine, as well as steps that are performed on the target WebSphere Commerce Server.

The following types of assets must be deployed to the target WebSphere Commerce Server:

This section describes how to deploy all of these assets, incrementally to the target WebSphere Commerce Server, in contrast to a deployment of the entire EAR file.


Procedure

  1. Create the command and data bean JAR file. This section describes how to create the JAR file that contains the controller command, task command, and data bean logic.

    1. Create a directory on the local file system called drive:\ExportTemp3, where drive is a drive on the local file system.

    2. Open WebSphere Commerce Developer and switch to the Project Navigator view.

    3. Navigate to the WebSphereCommerceServerExtensionsLogic project.

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

    5. In the Export wizard:

      1. Select Java > 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

        • .classpath.template

        • .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 JAR file field, enter the fully-qualified JAR file name to use. In this case, enter drive:\ExportTemp3\WebSphereCommerceServerExtensionsLogic.jar. Note that the JAR file name must be WebSphereCommerceServerExtensionsLogic.jar.

      7. Click Finish.

  2. Create the EJB JAR file

    1. Expand the WebSphereCommerceServerExtensionsData project.

    2. Open Deployment Descriptor: WebSphereCommerceServerExtensionsData.

    3. With the Overview tab selected, scroll to the bottom of the pane, to locate the JNDI - CMP Connection Factory Binding section.

    4. In the JNDI name field, enter the datasource JNDI name of the target WebSphere Commerce Server. The value for the DataSource JNDI name field is created by adding "jdbc/" to the value of the DatasourceName variable of the target WebSphere Commerce Server. You can verify the data source name by opening the WebSphere Commerce configuration file on the target WebSphere Commerce Server and searching for DatasourceName= in the file. The following values are examples :

      • jdbc/WebSphere Commerce DB2 DataSource demo where the target WebSphere Commerce Server is using a DB2 database, and the WCS instance name is demo.

      • jdbc/WebSphere Commerce Oracle DataSource demo where the target WebSphere Commerce Server is using an Oracle database, and the WCS instance name is demo.

      • jdbc/WebSphere Commerce iSeries DataSource demo where the target WebSphere Commerce Server is using an DB2 UDB for iSeries database, and the WCS instance name is demo.

      If you specify a different data source for the custom enterprise beans than that used by the WebSphere Commerce enterprise beans, a two-phase commit will be required. Therefore, if the custom enterprise beans use the same database as the WebSphere Commerce enterprise beans, use the same data source name, so as to avoid a two-phase commit. In general, the use of two-phase commit JDBC drivers with WebSphere Commerce is not recommended.

    5. Save and close the deployment descriptor.

    6. In the Enterprise Explorer view, from the WebSphereCommerceServerExtensionsData project's pop-up menu, select Export > EJB JAR file.

    7. In the Export wizard:

      1. The EJB project name is prepopulated. Leave this value as is.

      2. For the destination, enter the fully-qualified JAR file name to use. In this case, enter drive:\ExportTemp3\WebSphereCommerceServerExtensionsData.jar.

      3. Click Finish.

    8. After the JAR file has been created, undo the changes to the local deployment descriptor that was made in step 5, to restore the setting that is required for the local test server.

  3. Export store assets

    1. Switch to the Project Navigator view.

    2. Navigate to the Stores folder.

    3. From the Stores folder's pop-up menu, select Export > Export.

    4. In the Export wizard:

      1. Select General > File System and click Next.

      2. Click Deselect all.

      3. Select the following resources to deploy:

        • Stores\WebContent\ConsumerDirect_name\include\OrderSummaryDisplayInclude.jsp

        • Stores\WebContent\ConsumerDirect_name\include\OrderDetailDisplayInclude.jsp

        • Stores\WebContent\ConsumerDirect_name\ShoppingArea\CheckoutSection\StandardCheckoutSubsection\OrderConfirmationDisplay.jsp

        • Stores\WebContent\ConsumerDirect_name\Snippets\EDP\PaymentMethods\PaymentMethodsDisplay.jsp

        • Stores\WebContent\WEB-INF\classes\ConsumerDirect_name\ordergift.properties

      4. In the To directory field, drive:\ExportTemp.

      5. Select Create directory structure for files.

      6. Click Finish.

    5. On the file system navigate to drive:\ExportTemp.

    6. Rename the Stores directory to Stores.war.

    7. Navigate to the drive:\ExportTemp3\Stores.war\WebContent directory.

    8. Move the ConsumerDirect_name and WEB-INF directories and their contents into the Stores.war directory.

    9. Delete the now empty WebContent directory. The resulting files should look like the following:

      • Stores.war\ConsumerDirect_name\include\OrderSummaryDisplayInclude.jsp

      • Stores.war\ConsumerDirect_name\include\OrderDetailDisplayInclude.jsp

      • Stores.war\ConsumerDirect_name\ShoppingArea\CheckoutSection\StandardCheckoutSubsection\OrderConfirmationDisplay.jsp

      • Stores.war\ConsumerDirect_name\Snippets\EDP\PaymentMethods\PaymentMethodsDisplay.jsp

      • Stores.war\WEB-INF\classes\ConsumerDirect_name\ordergift.properties

    10. If necessary, rename the ConsumerDirect_name folder to match the consumer direct sample store name on the target machine.

    11. Use a ZIP file compression utility to compress the Stores.war files (that is, excluding WebSphereCommerceServerExtensionsData.jar and WebSphereCommerceServerExtensionsLogic.jar) into a file called drive:\ExportTemp3\StoreAssets.zip. Ensure that the directory structure is created correctly within the ZIP file.

  4. 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 gift order assets into this directory. This step is not necessary if you run the WebSphere Application Server administration console from the 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:\ImportTemp.

    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 \ExportTemp into \ImportTemp on the target WebSphere Commerce Server.

  5. 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 is the applicable port. The default port number is 9060.

    2. Click Applications > Application Types > WebSphere enterprise applications to see a list of installed applications.

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

  6. Update the database on the target WebSphere Commerce Server

  7. Register the task command implementation

    To modify the command registry:

    1. Register MyExtOrderProcessCmdImpl:

      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;
        insert into CMDREG (STOREENT_ID, INTERFACENAME, DESCRIPTION, 
           CLASSNAME, TARGET)
        values (CD_storeent_ID, 
           'com.ibm.commerce.order.commands.ExtOrderProcessCmd', 
           'This is a new task command for the object model tutorial.', 
           'com.ibm.commerce.sample.commands.MyExtOrderProcessCmdImpl',    'local');
        

        Where:

        targetDB

        is the name of the target database

        dbuser

        is database user

        dbpassword

        is the password of the database user

        CD_storeent_ID

        is the store identifier for the store

      6. Click the Execute icon. Keep the Command Editor open.

    2. Register MyExtOrderProcessCmdImpl:

      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:

        insert into CMDREG (STOREENT_ID, INTERFACENAME, DESCRIPTION, 
           CLASSNAME, TARGET)
        values (CD_storeent_ID, 
           'com.ibm.commerce.order.commands.ExtOrderProcessCmd', 
           'This is a new task command for the object model tutorial.', 
           'com.ibm.commerce.sample.commands.MyExtOrderProcessCmdImpl',    'local');
        

      6. Press Enter to run the SQL statement.

      7. Type commit; and press Enter commit the database changes.

  8. Create the XORDGIFT table

    The XORDGIFT database table contains the information about the gift message.

    Create the XORDGIFT database table:

    1. Open a DB2 command window.

    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. In the Script window, enter the following:

      connect to targetDB user dbuser using dbpassword;
      create table XORDGIFT (ORDERSID bigint not null, RECEIPTNAME varchar(50), 
      SENDERNAME varchar(50), MSGFIELD1 varchar(50), MSGFIELD2 varchar(50), 
      OPTCOUNTER smallint not null default 0, constraint p_xordgift primary key (ORDERSID), 
      constraint f_xordgift foreign key (ORDERSID) references ORDERS(ORDERS_ID) 
      on delete cascade);
      insert into XORDGIFT (ORDERSID) (select ORDERS_ID from ORDERS);
      

      Where:

      targetDB

      is the name of the target database

      dbuser

      is database user

      dbpassword

      is the password of the database user

    6. Click the Execute icon. The XORDGIFT table is now created.

    Create the XORDGIFT database table:

    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 statements:

      create table XORDGIFT (ORDERSID NUMBER NOT NULL, RECEIPTNAME VARCHAR(50), 
      SENDERNAME VARCHAR(50), MSGFIELD1 VARCHAR(50), MSGFIELD2 VARCHAR(50), 
      OPTCOUNTER smallint default 0 not null , constraint p_xordgift primary key (ORDERSID), 
      constraint f_xordgift foreign key (ORDERSID) references ORDERS(ORDERS_ID) 
      on delete cascade);
      insert into XORDGIFT (ORDERSID) (select ORDERS_ID from ORDERS);
      

      and press Enter to run the SQL statement. The XORDGIFT table is now created.

    6. Enter the following to commit the database changes:

      commit;
      

      and press Enter to run the SQL statement.

  9. 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 > Application Types > WebSphere 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. If the session times out, you can use the WebSphere Application Server command line utilities to export the EAR. For more information see "Exporting applications using scripting" topic in the WebSphere Application Server Information Center.

  10. Update the store with the modified store assets using the WebSphere Application Server administrative console:

    1. Open the WebSphere Application Server administrative console by entering the following URL in a Web browser: http://host:9060/ibm/console

      ...where host is the name of the target machine.

    2. Logon to the WebSphere Application Server administrative console.

    3. Click Applications > Application Types > WebSphere enterprise applications.

    4. Select the application name, for example WC_demo, and click Update.

    5. Select Replace, add, or delete multiple files.

    6. In the Upload the archive file with the new or replacement files section, specify the path to drive:\ImportTemp3\StoreAssets.zip.

    7. Click Next.

    8. Click OK. Leave the WebSphere Application Server administrative console open.

  11. Update the command and data bean JAR file on the target WebSphere Commerce Server

    In this section we will update the target WebSphere Commerce Server to use the new command and data bean JAR file,...

    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. If you are running the WebSphere Application Server administrative console on the target machine, select Local file system, since the files are local to the browser. If you are running the WebSphere Application Server administrative console on a different machine, select Remove file system, since the files are remote to the browser.

    5. In the Full path section specify the path to drive:\ImportTemp3\WebSphereCommerceServerExtensionsLogic.jar.

    6. Click Next.

    7. Click OK. Leave the WebSphere Application Server administrative console open.

    It is possible to update both the store assets 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.

    Tip: 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.

  12. Update the EJB JAR file on the target WebSphere Commerce Server

    In this section you update the target WebSphere Commerce Server to use the new EJB JAR file,...

    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 module.

    3. In the Specify the path beginning with the installed application archive file to the module to be replaced or added field, enter WebSphereCommerceServerExtensionsData.jar.

    4. In the Full path section specify the path to drive:\ImportTemp3\WebSphereCommerceServerExtensionsData.jar.

    5. Click Next.

    6. If the target machine is using Derby, select FastPath and click Next. You can then skip the remaining steps in 12f and continue to 12g.

      If the target machine is not using Derby, in the Preparing for the application installation screen:

      1. Select Override existing bindings.

      2. In the EJB 1.1 CMP bindings section, select Default bindings for EJB 1.1 CMPs.

      3. In the JNDI name field, enter the datasource JNDI name of the target WebSphere Commerce Server. For example:

        • jdbc/WebSphere Commerce DB2 DataSource myInstancewhere the target WebSphere Commerce Server is using a DB2 database, and the WCS instance name is myInstance

        • jdbc/WebSphere Commerce Oracle DataSource myInstancewhere the target WebSphere Commerce Server is using an Oracle database, and the WCS instance name is myInstance.

        • jdbc/WebSphere Commerce iSeries DataSource myInstance where the target WebSphere Commerce Server is using an iSeries database, and the WCS instance name is myInstance.

      4. In the username field, enter the user name of the database user.

      5. In the password and verify password fields, enter the password of the database user.

      Your screen should be similar to the following:

    7. Leave all other default values and click Next.

    8. On the Application Security Warnings screen, click Continue.

    9. On the Install New Application screen, click Step 10: Summary.

    10. A summary of changes displays. Click Finish.

    11. When the update completes successfully, click Save to Master Configuration.

    12. 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.

    13. Close the WebSphere Application Server administration console.

  13. 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.

  14. Verify the gift message functionality on the target WebSphere Commerce Server

    In this section, you verify that the gift message logic is functioning correctly on the target WebSphere Commerce Server by doing the following:

    1. Open a browser and enter the URL for the store that is based on the consumer direct sample store.

    2. Log on as a new user. For example, click Register and then create the user "TutorialUser".

    3. As the new registered user, browse through the store, add an item to the shopping cart, and then complete the purchase. You will be able to add a gift message to the order, as shown in the following screen capture:

    4. Complete the order by clicking Order now.

    5. On the Order Confirmation page, the gift message information displays near the bottom of the page:

< Previous | Next >


+

Search Tips   |   Advanced Search