Deprecated featureWebSphere Commerce Developer

Example: Enabling multiple store archives for a sample store in a development environment

You can set up a sample store within your development environment to use multiple store enterprise (EAR) archives. You can use the multiple archives to separate store pages for specific components into one archive, with the store pages for the remaining components in another archive.

Before you begin

Ensure that you complete the following tasks:

About this task

The sample store that is separated across multiple store EAR files in the following steps is based on the Aurora store that is provided with Feature Pack 7. The steps use a store ID value of 10651 for the Aurora store. If the store ID on your environment is different, replace the store ID with the value for your store ID.

These steps separate only order and payment store pages into a separated WAR file from remaining store pages. To separate a different store component into a new store WAR file, the EJB references, struts configuration, and code files that you need to move, change, or create are different.

Procedure

  1. Create an empty EAR application project for your store.
    1. Open WebSphere Commerce Developer and switch to the Enterprise Explorer view.
    2. Right-click within the Enterprise Explorer view. Select New > Enterprise Application Project.
    3. In the New EAR Application Project window, enter a value for the Project name for your new archive.
      For example, the following steps use WCStores1_demo as the value for the Project name.
    4. Click Finish.
  2. Create a store web (WAR) archive in the new EAR project.
    1. Right-click your new EAR project, WCStores1_demo. Select New > Dynamic Web Project.
    2. In the New Dynamic Web Project window, enter a value for the Project name.
      For example, the following steps use Stores1 as the value for the Project name.

      New Dynamic Web Project window

    3. Click Finish to create an empty WAR.
    4. Go to the Stores\WebContent\WEB-INF directory.
    5. Copy the following files and subfolders from the WEB-INF directory.
      • tiles-defs.xml
      • validator-rules.xml
      • *.tld
      • lib/Foundation-TagLib.jar
      • web.xml
    6. Go to the Stores1\WebContent\WEB-INF directory. Add the copied files and subfolders into this WEB-INF directory to add the files to your new WAR. Overwrite the web.xml that exists in your new WAR.
    7. In your Stores1\WebContent\WEB-INF directory, open the web.xml file for editing.
      Update the values for the display-name element, ServletName parameter, and the struts configuration files.
      For example, your updated web.xml values can resemble the following code snippet:
      <web-app ...
          <servlet>
               <display-name>Stores1</display-name>
               ......
                <init-param>
                  <param-name>config</param-name>
                  <param-value>...struts config files...</param-value>
               </init-param>
          </servlet>
          ......
           <filter>
              ......
              <init-param>
                  <param-name>ServletName</param-name>
                  <param-value>Stores1</param-value>
              </init-param>
          </filter>
         ......
      </web-app>
    8. Save and close the file.
  3. Configure the extended document root for your two store WAR files. The extended document root allows JSP file resources to be shared across WAR files.
    1. In your Stores1\WebContent\WEB-INF directory, open the ibm-web-ext.xml file for editing.
    2. Add the following element to configure the extended document root to point the JSP directory of your new store WAR to the Stores.war in your original store WAR file.
      <jsp-attribute name="extendedDocumentRoot" value="workspace_dir/Stores/WebContent" />    
    3. In your Stores\WebContent\WEB-INF directory, open the ibm-web-ext.xml file for editing.
    4. Add the following element to configure the extended document root to point the JSP directory of your old store WAR to the Stores1.war in your new store WAR file.
      <jsp-attribute name="extendedDocumentRoot" value="workspace_dir/Stores1/WebContent" />    
    5. Save and close the files.
      For more information about the extended document root property, see JSP engine configuration parameters.
  4. Copy the EJB references from your original store WAR file into your new store WAR file.
    1. In the Stores\WebContent\WEB-INF directory, open the ibm-web-bnd.xml file for editing.
    2. Copy the following EJB references:
      <ejb-ref name="ejb/BusinessContextServiceWrapperLocal" 
       binding-name="ejb/com/ibm/commerce/component/contextservice/objects/BusinessContextServiceWrapperHome" />
      <ejb-ref name="ejb/MemberGroupMemberService" 
       binding-name="ejb/com/ibm/commerce/user/objects/service/MemberGroupMemberServiceLocalHome" />
      <ejb-ref name="ejb/ContextManagement" 
       binding-name="ejb/com/ibm/commerce/context/objects/ContextManagementHome" />
      <ejb-ref name="ejb/ContextData" 
       binding-name="ejb/com/ibm/commerce/context/objects/ContextDataHome" /></web-bnd>
    3. Go to the Stores1\WebContent\WEB-INF directory, and open the ibm-web-bnd.xml file for editing.
    4. Add the copied EJB references into the file. Then, save and close the file.
  5. Update the struts configuration files for your original store WAR.
    1. Download and extract the following struts template for your original store WAR in a temporary folder.
    2. Copy the files in the extracted struts templates temporary folder.
    3. Go to the Stores\WebContent\WEB-INF directory.
    4. Add the copied files to the directory and override the existing struts configuration files.
  6. Create the struts configuration files for your new store WAR.
    1. Download and extract the following struts template for your original store WAR in a temporary folder.
    2. Copy the files in the extracted struts templates temporary folder.
    3. Go to the Stores1\WebContent\WEB-INF directory.
    4. Add the copied files to the directory to create the struts configuration files.
  7. Move your order and payment store pages into the new store WAR file.
    1. Go to the Stores\WebContent\store_name directory in the original store war, where store_name is the name of your store, for instance Aurora.
    2. Copy the following store file structure and files. Where * is identified, copy all subfolders and files in the identified directory.
      • ShoppingArea/CheckoutSection/*
      • ShoppingArea/OrderCreationSection/*
      • ShoppingArea/ShopcartSection/*
      • Snippet/EDP/*
      • Snippet/Order/*
    3. Go to the Stores1\WebContent\store_name folder in the new store WAR. If the folder structure does not exist, you must create this structure.
    4. Add the copied store file structure and files to the new store WAR.
  8. Enable multiple store WAR files for your WebSphere Commerce instance in the wc-server.xml for your site:
    1. Go to the workspace_dir\WC\xml\config directory and open the wc-server.xml file for editing.
    2. Search for StoreWebModuleName="Stores" in the file. Add the configuration MultipleStoreWARs="true" to the file
      For example,
      <Instance
        ...
        StoreWebModuleName="Stores"
        MultipleStoreWARs="true"
        .../>
    3. Save and close the file. You must republish the WebSphere Commerce application before the change takes effect.
  9. Add the new store EAR, WCStores1_demo, to the WebSphere Commerce Test Server.
    1. Right-click the WebSphere Commerce Test Server. Select Add and Remove.
    2. Select WCStores1_demo and click Add to add the project to the WebSphere Commerce Test Server.
    3. Right-click the WebSphere Commerce Test Server. Click Publish.
    4. Restart the WebSphere Commerce Test Server.
  10. Deploy the new store WAR module by adding the module to your new store EAR. For more information, see Deploying a WAR module.
  11. Configure the context roots for the new store WAR, Stores1, within the new store EAR, WCStores1_demo.
    1. In the new store EAR, go to the Stores1\META-INF directory and open the application.xml file for editing.
    2. Add the context root information for the new Stores1 WAR.
      For example, the updated file can resemble the following code snippet
      <?xml version="1.0" encoding="UTF-8"?>
      <application id="Application_ID" version="5" 
       xmlns="http://java.sun.com/xml/ns/javaee" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
       http://java.sun.com/xml/ns/javaee/application_5.xsd">
      ...
       <display-name>WCStores1_demo</display-name>
       <module id="Module_1396511150409">
        <web>
          <web-uri>Stores1.war</web-uri>
          <context-root>/webapp/wcs/Stores1</context-root>
        </web>
       </module>
      ...
      </application>
    3. Save and close the file.
  12. Configure the order that the new EAR starts within the WebSphere Commerce application. The WebSphere Commerce EAR must start before any store EAR.
    1. Go to the WCDE_installdir\wasprofile\config\cells\localhost\applications\WCStores1_demo.ear\deployments\WCStores1_demo directory and open the deployment.xml file for editing.
    2. In the <appdeployment configuration, search for the startingWeight attribute. Set the value for the attribute to be higher than the value for the WebSphere Commerce EAR.
      For example, set the value to be "100"
      <appdeployment:Deployment ... >
        <deployedObject... startingWeight="100" ... >
    3. Save and close the file.
  13. Add any resource bundle files that are used by files in both store EAR files into the shared library.
    1. In the WebSphere Application Server, expand Environment. Click Shared libraries.
    2. Click the shared library that you need to update. The General Properties for the library open.
    3. Edit the list class paths in the library to add or update the appropriate class paths.
      For example, add the properties files in the following directories into the shared library:
      • workspace_dir/Stores/WebContent/WEB-INF/classes
      • workspace_dir/Stores1/WebContent/WEB-INF/classes
    4. Click Apply > Save directly to the master configuration.
  14. Restart the WebSphere Commerce Test Server.
  15. Publish your new store EAR on the WebSphere Commerce Test server. Right-click the WebSphere Commerce Test Server and select Publish.
  16. Open your store and complete a shopping flow to verify that your store functions correctly.

What to do next

You can use the multiple store archive setup in your development environment to set up a sample store to work with multiple store archives in your production environment. For more information, see Example: Enabling multiple store archives for a sample store in a production environment.