Tutorials > Management Center > Add new fields in the Catalogs tool
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
- Export the LOBTools project:
- In the Enterprise Explorer view, expand .
- Right-click LOBTools and select Export > WAR file.
- Click Browse to select a destination.
- Click Finish.
- Export the WebSphereCommerceServerExtensionsLogic project:
- In WebSphere Commerce Developer, switch to the Enterprise Explorer view view.
- Navigate to Other Projects > WebSphereCommerceServerExtensionsLogic.
- Right-click the WebSphereCommerceServerExtensionsLogic project and select Export. The Export wizard opens.
- In the Export wizard:
- Click JAR file > Next. The project WebSphereCommerceServerExtensionsLogic is selected by default. Leave this value selected.
- In the right pane, ensure that resources that begin with a period are not selected. For example:
- .classpath
- .classpath.template
- .project
- .runtime
- Ensure thatExport generated class files and resources is selected.
- Uncheck Export Java source files and resources.
- In the Select the export destination field, type the fully-qualified JAR file name to use. In this case, typedrive:\ExportTemp\WebSphereCommerceServerExtensionsLogic.jar.
- Click Finish.
- 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.
- 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.
- In the Enterprise Explorer view, navigate to the Stores folder.
- Right-click the Stores folder and select Export > Export.
- In the Export wizard:
- Select File System and click Next.
- Click Deselect All.
- 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
- In the To directory field, enter a temporary directory, for example drive:\ExportTemp.
- Ensure the Create directory structure for files option is selected.
- Click Finish.
- In the file system, navigate to the temporary directory, for example drive:\ExportTemp.
- Rename the Stores directory to Stores.war.
- Navigate to the Stores.war\WebContent directory.
- Move the ConsumerDirect_name and WEB-INF directories and their contents under the Stores.war directory
- 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
- If applicable, rename all the ConsumerDirect_name folders to match the name of the consumer direct sample store on your target machine.
- 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.
- On the target server, navigate to WC_EAR/Stores.war/WEB-INF .
- 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.
- Open the copied struts-config-ext.xml file in a text editor.
- Locate the following tag:</global-forwards>.
- 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.
- Locate the following tag: </action-mappings>.
- 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.
- Save and close the file.
- Compress the store assets into one file.
- 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.
- Name the file partialApp.zip, for example drive:\ExportTemp\partialApp.zip.
- Copy the access control policies that were created for your new resources:
- Navigate to the WC_EAR\xml\policies\xml directory.
- Copy the following files into the drive:\ExportTemp\ACPolicies directory:
- MyCompanyCatalogAccessControlPolicies.xml
- WarrantyviewCommand.xml
- Create database tables and access control policies on the target WebSphere Commerce Server.
- 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'
- Connect to the DB2 database.
- 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');
- Connect to the Oracle database.
- 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');
- Enter the following to commit the database changes:
commit;and press Enter to run the SQL statement.
- Load access control policies on the target WebSphere Commerce Server:
- Copy the following access control policies into the WC_INSTALL\xml\policies\xml directory:
- MyCompanyCatalogAccessControlPolicies.xml
- WarrantyviewCommand.xml
- At a command prompt, navigate to the following directory: WC_INSTALL\bin
- 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.
- Ensure the four input XML files have the same permissions and ownership as other files in the WC_INSTALL/xml/policies/xml directory.
- 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.
- Issue the acpload command, which has the following form:
acpload targetDB dbuser dbpassword inputXMLFile schema_nameWhere:
- 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
- Repeat the previous step for each of the following access control policies:
- MyCompanyCatalogAccessControlPolicies.xml
- WarrantyviewCommand.xml
- Check for any error logs that might have been generated while the access control policies were loaded:
- Check the following files:
- WC_INSTALL/logs/trace.log
- WC_INSTALL/logs/acpload.log
- Check the following files:
- Deploy code on the target WebSphere Commerce Server.
- Export a backup copy of the WebSphere Commerce EAR, so that you can revert to the old version in the future if desired:
- In the WebSphere Application Server administrative console, click Applications > Application Types > WebSphere enterprise applications to see a list of installed applications.
- Select the WebSphere Commerce application, for example WC_demo, and click Export.
- Follow the wizard and save the EAR file in a backup directory.
- Deploy the LOBTools.war:
- In the WebSphere Application Server, select administrative console. Expand Applications > Application Types > WebSphere enterprise applications .
- Check the combo box in front of the application name, for example, WC_demo, and click Update.
- Select Replace or add a single module and change the Full path to the path.
- Click Next.
- In the next screen, do not make any changes and click Next.
- In the next screen, click Next without any input.
- 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.
- Click Next, and then click Finish.
- When the update completes, click Save to save the Master Configuration.
- Deploy WebSphereCommerceServerExtensionsLogic.jar and XML config files:
- In the WebSphere Application Server administrative console, click Applications > Application Types > WebSphere enterprise applications.
- Select the application name, for example WC_demo, and click Update.
- Select Select Replace, add, or delete multiple files.
- Change the Full path to the location of partialApp.zip, for example, drive:\ImportTemp\partialApp.zip.
- Click OK.
- When the update completes, click Save to save the Master Configuration. In the next page, Updating Application, click OK.
- Export the following file from the development environment: Stores > Java Resources > src > ConsumerDirect > storetext.properties
- In the WebSphere Application Server administrative console, click Applications > Enterprise Applications.
- Select the application name, for example WC_demo, and click Update.
- Select Single File.
- In the Relative path to file field, type Stores.war\WEB-INF\classes\ConsumerDirect\storetext.properties
- 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.
- Click Next.
- Click OK.
- When the update completes, click Save to save the Master Configuration.