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

About this task
- Create the JAR file that contains the command logic and error classes.
- Export the error message properties file.
- Transfer the assets to the target WebSphere Commerce Server.
- Update the command registry on the target WebSphere Commerce Server.
- 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
- 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:
- Create a directory on your local file system called drive:\ExportTemp2.
- Open the WebSphere Commerce development environment Project Navigator view.
- Right click WebSphereCommerceServerExtensionsLogic and select Export.
- In the export wizard:
- Expand the Java folder. Select the JAR file and click Next.
- The left pane under Select the resources to export is prepopulated with the name of the project. Leave this value as is.
- In the right pane, ensure that resources that begin with a period
are not selected. For instance:
- .classpath
- .project
- .serverPreference
- .runtime
- Ensure that Export generated class files and resources is selected.
- Do not select Export Java source files and resources.
- 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. - Click Finish.
- Export the properties file that contains the text for the
new message:
- In the Project Navigator view, expand the Stores folder.
- Right-click the WebContent folder and select Export.
- In the export wizard:
- Expand the General folder. Select File system and click Next.
- Click Deselect All.
- Select to export the following resource: Web Content\WEB-INF\classes\MyNewErrorMessages.properties
- Select Create directory structure for files.
- 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
- Click Finish.
- 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:
- On the target WebSphere Commerce Server, create a temporary directory called drive:\ImportTemp2.
- 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.
- From the development machine, copy the contents of drive:\ExportTemp2 into drive:\ImportTemp2 on the target WebSphere Commerce Server.
- To stop your target WebSphere Commerce application, open
the WebSphere Application Server administration console and stop the
WebSphere Commerce application:
- 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, andportnumber
you chose at installation time. The default port number is 9060. - Click Applications > Application types > WebSphere enterprise applications to see a list of installed applications.
- Select your WebSphere Commerce application.For example, WC_demo, and click Stop.
- Open the WebSphere Application Server administrative
console by entering the following URL in a web browser:
- 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.
Register MyOrderItemAddCmdImpl:
- Open the DB2 Command Editor (Start > Programs > IBM DB2 > Command Line Tools > Command Editor).
- From the Tools menu, select Tools Settings.
- Select the Use statement termination character check
box and ensure the character that is specified is a semicolon (
;
). - Close the Tools Settings.
- With the Script tab selected, create the required entry
in the CMDREG table, by entering the following information in the
script window:
Where: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;
- 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.
- Click the Execute icon.
Register MyOrderItemAddCmdImpl:
- 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).
- In the User Name field, enter your Oracle user name.
- In the Password field, enter your Oracle password.
- In the Host String field, enter your connect string.
- In the SQL Plus window, enter the
following SQL statement:
Press Enter to run the SQL statement.update CMDREG set CLASSNAME='com.ibm.commerce.sample.commands.MyOrderItemAddCmdImpl' WHERE INTERFACENAME= 'com.ibm.commerce.orderitems.commands.OrderItemAddCmd' and storeent_Id=0;
- Enter the following statement to commit your database
changes:
Press Enter to run the SQL statement.commit;
- Export a backup copy the EARTip: Export a backup copy of the EAR, so that you can revert to the old version in the future if needed:
- In the WebSphere Application Server administrative console, click Applications > Application types > WebSphere enterprise applications to see a list of installed applications.
- Select your WebSphere Commerce application, for example WC_demo, and click Export.
- Follow the wizard and save your EAR file in a backup directory. If the EAR file is large, this action might take some time.
- 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:
- In the WebSphere Application Server administrative console,
select your application name.For example, WC_demo, and click Update.
- Select Replace or add a single file.
- In the Specify the path beginning with the installed application archive file to the file to be replaced or added field, enter WebSphereCommerceServerExtensionsLogic.jar.
- In the Specify the path to the file box, specify the path to your copied file, such as drive:\ImportTemp\WebSphereCommerceServerExtensionsLogic.jar.
- Click Next.
- Click OK.
- 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.
- In the WebSphere Application Server administrative console,
select your application name.
- Updating the MyNewErrorMessages.properties file
on the target WebSphere Commerce Server. Add the JSP, JSPF, and properties
files to the application:
- In the WebSphere Application Server administrative console,
select your application name.For example, WC_demo, and click Update.
- Select Replace or add a single File.
- 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
. - In the Specify the path to the file box, specify the path to your copied file: drive:\ImportTemp\MyNewErrorMessages.properties.
- Click Next.
- Click OK.
- When the update completes successfully, click Save to Master Configuration.
- 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.
- 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. - In the WebSphere Application Server administrative console,
select your application name.
- You must stop and start your WebSphere Application Server
before you can view the changes that you deployed. To stop and start
your server.
- At a command prompt, navigate to WC_profiledir\bin.
- 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. - 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. - Go to the WC_profiledir\logs\server1 directory.
- Examine the SystemOut.log file. Ensure that the server started successfully without errors.
- 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