Tutorials > Management Center > Add new fields in the Catalogs tool

< Previous | Next >


Deploy the customized code

In this lesson, you deploy the custom code to a target WebSphere Commerce Server. Deploying to the server involves exporting code from WebSphere Commerce development environment and deploying code into target WebSphere Commerce Server.

You must have created a store, based upon the consumer direct sample store, on the remote WebSphere Commerce Server before starting these deployment steps.


Procedure

  1. Export the LOBTools project:

    1. In the Enterprise Explorer view, expand .

    2. Right-click LOBTools and select Export > WAR file.

    3. Click Browse to select a destination.

    4. Click Finish.

  2. Export the WebSphereCommerceServerExtensionsLogic project:

    1. In WebSphere Commerce Developer, switch to the Enterprise Explorer view view.

    2. Navigate to Other Projects > WebSphereCommerceServerExtensionsLogic.

    3. Right-click the WebSphereCommerceServerExtensionsLogic project and select Export. The Export wizard opens.

    4. In the Export wizard:

      1. Click JAR file > Next. The project WebSphereCommerceServerExtensionsLogic is selected by default. Leave this value selected.

      2. In the right pane, ensure that resources that begin with a period are not selected. For example:

        • .classpath

        • .classpath.template

        • .project

        • .runtime

      3. Ensure thatExport generated class files and resources is selected.

      4. Uncheck Export Java source files and resources.

      5. In the Select the export destination field, type the fully-qualified JAR file name to use. In this case, typedrive:\ExportTemp\WebSphereCommerceServerExtensionsLogic.jar.

      6. Click Finish.

  3. Export data service layer extension configuration files.

    For XML configuration files, copy these assets to the directory you are using to build the deployment package. The structure under this directory must match the structure that you want inside the EAR file. In the file system, navigate to the temporary directory, for example, drive:\ExportTemp. Create directory like xml\config\com.ibm.commerce.catalog-ext. Copy the files under drive\WC_EAR\xml\config\com.ibm.commerce.catalog-ext into drive:\ExportTemp\xml\config\com.ibm.commerce.catalog-ext. For this tutorial, these files include wc-component.xml, wc-business-object-mediator.xml, wc-object-relational-metadata.xml, as well as query templates files. For example, wc-query-MyCompanyCatalogEntry-get.tpl.

  4. Export store assets:

    Store assets include the JSP pages and properties files that display in the store. WebSphere Application Server expects the files to be in a directory structure that matches the target file structure. In this step, after you export the files from Rational Application Developer we will modify the file structure to match the file structure on the target machine.

    1. In the Enterprise Explorer view, navigate to the Stores folder.

    2. Right-click the Stores folder and select Export > Export.

    3. In the Export wizard:

      1. Select File System and click Next.

      2. Click Deselect All.

      3. Select the following assets:

        • Stores\WebContent\ConsumerDirect_name\ShoppingArea\CatalogSection\CatalogEntrySubsection\ProductDisplay.jsp

        • Stores\WebContent\ConsumerDirect_name\ShoppingArea\CatalogSection\CatalogEntrySubsection\WarrantyDisplay.jsp

        • Stores\WebContent\WEB-INF\config\com.ibm.commerce.catalog-ext\get-data-config.xml

      4. In the To directory field, enter a temporary directory, for example drive:\ExportTemp.

      5. Ensure the Create directory structure for files option is selected.

      6. Click Finish.

    4. In the file system, navigate to the temporary directory, for example drive:\ExportTemp.

    5. Rename the Stores directory to Stores.war.

    6. Navigate to the Stores.war\WebContent directory.

    7. Move the ConsumerDirect_name and WEB-INF directories and their contents under the Stores.war directory

    8. Delete the now empty WebContent directory. The resulting file structure should look like the following:

      • Stores.war\ConsumerDirect_name\ShoppingArea\CatalogSection\CatalogEntrySubsection\ProductDisplay.jsp

      • Stores.war\ConsumerDirect_name\ShoppingArea\CatalogSection\CatalogEntrySubsection\WarrantyDisplay.jsp

      • Stores.war\WEB-INF\config\com.ibm.commerce.catalog-ext\get-data-config.xml

    9. If applicable, rename all the ConsumerDirect_name folders to match the name of the consumer direct sample store on your target machine.

  5. Update the struts-config-ext.xml file in store assets.

    The struts-config-ext.xml file is updated every time you publish a store. Although it is possible to export the struts-config-ext.xml file from the development machine and deploy it to the target WebSphere Commerce Server, problems may arise when the store ID's on the development machine do not exactly match the store ID's on the target machine. To avoid this mismatch, the following steps update the struts-config-ext.xml file instead of deploying the development version.

    1. On the target server, navigate to WC_EAR/Stores.war/WEB-INF .

    2. Place a copy of the struts-config-ext.xml file in the Stores.war/WEB-INF folder of the temporary directory on the development machine, for example drive:\ExportTemp\Stores.war\WEB-INF.

    3. Open the copied struts-config-ext.xml file in a text editor.

    4. Locate the following tag:</global-forwards>.

    5. Insert the following text just before the </global-forwards> tag:

      <forward className="com.ibm.commerce.struts.ECActionForward" name="WarrantyView/511" path="/ShoppingArea/CatalogSection/CatalogEntrySubsection/WarrantyDisplay.jsp"/> 
      

      Replace the sample store ID, "511" with the own store ID.

    6. Locate the following tag: </action-mappings>.

    7. Insert the following text just before the </action-mappings> tag:

      <action path="/WarrantyView" type="com.ibm.commerce.struts.BaseAction">
      <set-property property="https" value="511:1"/>
      </action>
      

      Replace the sample store ID, "511" with the own store ID.

    8. Save and close the file.

  6. Compress the store assets into one file.

    1. Use a ZIP utility to create a compressed file. The compressed file must contain all assets under the ExportTemp directory. The ZIP file should maintain the original directory structure.

    2. Name the file partialApp.zip, for example drive:\ExportTemp\partialApp.zip.

  7. Copy the access control policies that were created for your new resources:

    1. Navigate to the WC_EAR\xml\policies\xml directory.

    2. Copy the following files into the drive:\ExportTemp\ACPolicies directory:

      • MyCompanyCatalogAccessControlPolicies.xml

      • WarrantyviewCommand.xml

  8. Create database tables and access control policies on the target WebSphere Commerce Server.

    1. Create the XWARRANTY and XCAREINSTRUCTION tables in the database used by the target WebSphere Commerce Server:

      In the following SQL samples, 511 is the sample store ID. Replace this value with the store ID. The values 51100000001, 51100000003, and 51100000005 are sample CATENTRY_ID values in the tutorial test production environment, which match the CATENTRY_ID values of 10251, 10253, and 10255 in a development environment. Execute the following SQL statement to query the CATENTRY_ID values in the environment:

      select CATENTRY_ID from catentry where member_id=(select member_id from storeent where storeent_id=511) and CATENTTYPE_ID='ProductBean'
      

      1. Connect to the DB2 database.

      2. In the Script window, run the following SQL statement:

        CREATE TABLE XWARRANTY (CATENTRY_ID BIGINT NOT NULL, WARTERM INTEGER, WARTYPE VARCHAR(32), OPTCOUNTER SMALLINT, CONSTRAINT XWARRANTY_PK PRIMARY KEY(CATENTRY_ID), CONSTRAINT XWARRANTY_FK FOREIGN KEY (CATENTRY_ID) REFERENCES CATENTRY(CATENTRY_ID));
        
        CREATE TABLE XCAREINSTRUCTION (
        CATENTRY_ID BIGINT NOT NULL, LANGUAGE_ID INTEGER NOT NULL, CAREINSTRUCTION VARCHAR(254), OPTCOUNTER SMALLINT, CONSTRAINT XCAREINST_PK PRIMARY KEY (CATENTRY_ID, LANGUAGE_ID), CONSTRAINT XCAREINST_FK1 FOREIGN KEY (CATENTRY_ID, LANGUAGE_ID) REFERENCES CATENTDESC(CATENTRY_ID, LANGUAGE_ID), CONSTRAINT XCAREINST_FK2 FOREIGN KEY (CATENTRY_ID) REFERENCES CATENTRY (CATENTRY_ID)
        );
        
        INSERT INTO XWARRANTY (CATENTRY_ID, WARTERM, WARTYPE) VALUES (51100000001, 30, 'LIMITED'); 
        INSERT INTO XWARRANTY (CATENTRY_ID, WARTERM, WARTYPE) VALUES (51100000003, 45, 'COMPREHENSIVE'); 
        INSERT INTO XWARRANTY (CATENTRY_ID, WARTERM, WARTYPE) VALUES (51100000005, 60, 'LIMITED');
        
        INSERT INTO XCAREINSTRUCTION (CATENTRY_ID, LANGUAGE_ID, CAREINSTRUCTION) VALUES (51100000001, -1, 'Never use an abrasive cleaner or material on any finished product');
        INSERT INTO XCAREINSTRUCTION (CATENTRY_ID, LANGUAGE_ID, CAREINSTRUCTION) VALUES (51100000003, -1, 'Avoid soap and water');
        INSERT INTO XCAREINSTRUCTION (CATENTRY_ID, LANGUAGE_ID, CAREINSTRUCTION) VALUES (51100000005, -1, 'Never use household cleaners');
        

      1. Connect to the Oracle database.

      2. In the SQL Plus window, execute the following SQL statement:

        CREATE TABLE XWARRANTY
        ( 
        CATENTRY_ID NUMBER NOT NULL, WARTERM INTEGER, WARTYPE VARCHAR(32), OPTCOUNTER SMALLINT, CONSTRAINT XWARRANTY_PK PRIMARY KEY(CATENTRY_ID), CONSTRAINT XWARRANTY_FK FOREIGN KEY (CATENTRY_ID) REFERENCES CATENTRY(CATENTRY_ID)
        );
        CREATE TABLE XCAREINSTRUCTION (
        
        CATENTRY_ID NUMBER NOT NULL, 
        LANGUAGE_ID INTEGER NOT NULL, 
        CAREINSTRUCTION VARCHAR(254), 
        OPTCOUNTER SMALLINT, 
        CONSTRAINT XCAREINSTRUCTION_PK PRIMARY KEY (CATENTRY_ID, LANGUAGE_ID), 
        CONSTRAINT XCAREINSTRUCTION_FK1 FOREIGN KEY (CATENTRY_ID, LANGUAGE_ID) 
        REFERENCES CATENTDESC(CATENTRY_ID, LANGUAGE_ID), 
        CONSTRAINT XCAREINSTRUCTION_FK2 FOREIGN KEY (CATENTRY_ID) REFERENCES CATENTRY 
        (CATENTRY_ID)
        
        );
        INSERT INTO XWARRANTY (CATENTRY_ID, WARTERM, WARTYPE) VALUES (51100000001, 30, 'LIMITED');
        INSERT INTO XWARRANTY (CATENTRY_ID, WARTERM, WARTYPE) VALUES (51100000003, 45, 'COMPREHENSIVE');
        INSERT INTO XWARRANTY (CATENTRY_ID, WARTERM, WARTYPE) VALUES (51100000005, 60, 'LIMITED');
        
        INSERT INTO XCAREINSTRUCTION (CATENTRY_ID, LANGUAGE_ID, CAREINSTRUCTION) VALUES (51100000001, -1, 'Never use an abrasive cleaner or material on any finished product');
        INSERT INTO XCAREINSTRUCTION (CATENTRY_ID, LANGUAGE_ID, CAREINSTRUCTION) VALUES (51100000003, -1, 'Avoid soap and water');
        INSERT INTO XCAREINSTRUCTION (CATENTRY_ID, LANGUAGE_ID, CAREINSTRUCTION) VALUES (51100000005, -1, 'Never use household cleaners');
        

      3. Enter the following to commit the database changes:

        commit;
        

        and press Enter to run the SQL statement.

    2. Load access control policies on the target WebSphere Commerce Server:

      1. Copy the following access control policies into the WC_INSTALL\xml\policies\xml directory:

        • MyCompanyCatalogAccessControlPolicies.xml

        • WarrantyviewCommand.xml

      2. At a command prompt, navigate to the following directory: WC_INSTALL\bin

      3. Ensure you are logged in as wasuser_ID, where wasuser_ID is the non-root user ID created before installing WebSphere Commerce. The default WebSphere Application Server user name is wasuser.

      4. Ensure the four input XML files have the same permissions and ownership as other files in the WC_INSTALL/xml/policies/xml directory.

      5. Ensure you are logged in a profile that can read, write, and execute files under WC_INSTALL/xml/policies, WC_USER/instances and WC_USER/instances/instanceName/logs. For example, define the profile with USRCLS *SECOFR.

      6. Issue the acpload command, which has the following form:

        acpload targetDB dbuser dbpassword inputXMLFile schema_name
        

        Where:

        targetDB

        is the name of the development database.

        dbuser

        is the name of the database user.

        dbpassword

        is the password for the database user.

        inputXMLFile

        is the XML file containing the access control policy specification. In this case, specify MyCompanyCatalogAccessControlPolicies.xml

        schema_name

        The following example demonstrates the command with variables specified:

        acpload Demo_Dev db2admin db2admin MyCompanyCatalogAccessControlPolicies.xml DBUSER
        

      7. Repeat the previous step for each of the following access control policies:

        • MyCompanyCatalogAccessControlPolicies.xml

        • WarrantyviewCommand.xml

      8. Check for any error logs that might have been generated while the access control policies were loaded:

        • Check the following files:

        • Check the following files:

          • WC_USER/instances/acpload.log

          • WC_USER/instances/

          • instanceName/logs/messages.txt.

  9. Deploy code on the target WebSphere Commerce Server.

    1. Export a backup copy of the WebSphere Commerce 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.

    2. Deploy the LOBTools.war:

      1. In the WebSphere Application Server, select administrative console. Expand Applications > Application Types > WebSphere enterprise applications .

      2. Check the combo box in front of the application name, for example, WC_demo, and click Update.

      3. Select Replace or add a single module and change the Full path to the path.

      4. Click Next.

      5. In the next screen, do not make any changes and click Next.

      6. In the next screen, click Next without any input.

      7. To map the module to the servers, select the Module, press CTRL and select Clusters and Servers that are running the WebSphere Commerce application and click Apply. Click Next.

      8. Click Next, and then click Finish.

      9. When the update completes, click Save to save the Master Configuration.

    3. Deploy WebSphereCommerceServerExtensionsLogic.jar and XML config files:

      1. In the WebSphere Application Server administrative console, click Applications > Application Types > WebSphere enterprise applications.

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

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

      4. Change the Full path to the location of partialApp.zip, for example, drive:\ImportTemp\partialApp.zip.

      5. Click OK.

      6. When the update completes, click Save to save the Master Configuration. In the next page, Updating Application, click OK.

    4. Export the following file from the development environment: Stores > Java Resources > src > ConsumerDirect > storetext.properties

      1. In the WebSphere Application Server administrative console, click Applications > Enterprise Applications.

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

      3. Select Single File.

      4. In the Relative path to file field, type Stores.war\WEB-INF\classes\ConsumerDirect\storetext.properties

      5. In the New or replacement files section, check the local file system and click browse and specify the path to the storetext.properties file you exported.

      6. Click Next.

      7. Click OK.

      8. When the update completes, click Save to save the Master Configuration.

< Previous | Next >


+

Search Tips   |   Advanced Search