You can use the WebSphere Application Server – Deploy plug-in for IBM UrbanCode Deploy to deploy an enterprise application (EAR file) to multiple clusters in the same cell. In the following example, the EAR file EAR1.ear contains an Enterprise JavaBeans (EJB) Module, EJB1.jar.
A typical deployment process consists of the following steps:
- Running the Configure using Topology Discovery action, which creates a set of clusters and cluster member resources in the application environment, as shown in the following screen capture.
- Creating a component, based on the WebSphere Enterprise Application component template, that contains the EAR file.
- Adding the component under each cluster in the environment, as shown in the following screen capture.
- Creating an application process that runs the Install Component step, and then calls a process that is derived from the Deploy EAR With User/Group Mappings, Resource Mappings process. The Deploy EAR With User/Group Mappings, Resource Mappings process is provided by the WebSphere Enterprise Application component template.
This approach attempts to install the application, in parallel, on each cluster. This approach succeeds on one cluster but fails on the other clusters. An error similar to following message is logged:
com.ibm.ws.scripting.ScriptingException: WASX7279E: An application with name “EAR1” already exists. Select a different name.
To work around this error, you must deploy the application to one cluster only, and then map each module of the application to the other clusters. Complete the following steps:
- In the environment, create a resource tag called ClusterForInstall. Apply the tag to the first cluster.
- Create a resource tag called ClusterForMapping, and apply the tag to all of the remaining clusters.
- Go to the Components page, open the component (in this example,
MultipleClustersComp), and then click the Processes tab.
- In the Actions field that is associated with the Add Target to Module process, click Copy.
- In the Process Clipboard, click Paste.
- Rename the copy of the process to Add Target to Module for Cluster. Open the process for editing.
- Add an Add Target to Module step for each module contained in the EAR file, by clicking Application Server > Java > WebSphere > Deployment > Add Target to Module in the step palette of the process editor. Ensure that the step name is unique.
- Specify the name of the module to map to the cluster in the Module URI field. In this example, it is an EJB JAR file called EJB1.jar, as shown in the following screen capture:
- Optional: Click Show Hidden Properties to see all of the pre-populated values. The Cluster Name is known at run time because the component is under the cluster in the environment resource tree in IBM UrbanCode Deploy. When the step runs, the module is mapped to the selected cluster. You do not have to specify the cluster name explicitly in the step.
- Repeat steps 7-8 for each module contained in the EAR file.
- Create or update an application process, so that the process installs the component to the first cluster only, and maps the modules to all the other clusters, as shown in the following example:
- The first step in the previous example is an Install Component step, as shown in the following screen capture.
Component Process is set to the Deploy EAR deployment process, which installs the EAR file.
Limit to Tag is set to ClusterForInstall.
Max # of concurrent jobs is set to 1.
- The second step in the example is an Install Component step, as shown in the following screen capture.
Component Process is set to the Add Target To Module For Cluster deployment process, which you created previously in step 6.
Limit to Tag is set to ClusterForMapping.
Max # of concurrent jobs is set to 1.
- Because both processes are of type Deploy, when the application process runs, the selected component version is deployed to each cluster in the IBM UrbanCode Deploy inventory.
- The following screen capture shows a successful run of the application process:
The Deploy EAR process ran only once (on Cluster1), while the process Add Target to Module for Cluster ran twice (on Cluster2 and Cluster3).
- The component processes to start and stop the application are supplied by the WebSphere Enterprise Application component template. These processes are of type Operational (No Version needed). When you are working in the application process editor, you can find these start and stop processes listed in the step palette, under the name of the component that they belong to (in this example, the
MultipleClustersCompcomponent). Running these start and stop processes does not change the IBM UrbanCode Deploy inventory. Because the start and stop processes can be run in parallel on all clusters without error, you can leave the default value of the Max # of concurrent jobs field set to -1.
- The following screen capture shows the Start App process running in parallel on the three clusters:
- To uninstall the Application, create two component processes of type Uninstall. The first process actually uninstalls the EAR file from WebSphere Application Server. The second process is needed to remove the component version from the IBM UrbanCode Deploy inventory on the remaining clusters.
- Create a component process of type Uninstall, named Uninstall.
- Add the uninstall step to the component process by clicking Application Server > Java > WebSphere > Deployment > Uninstall Application in the step palette of the process editor. Accept all of the default properties for the step.
- Create another component process of type Uninstall, named Undo Target Mappings. Do not add steps to this process. Instead, add a note that explains the purpose of the process, as shown in the following screen capture:
- Create an application process that runs both of the component processes on different clusters, using Uninstall Component steps.
- The first uninstall step is defined as shown in the following screen capture:
- The second uninstall step is defined as shown in the following screen capture:
- The first process runs only once on Cluster1 and the second process runs on all other clusters (Cluster2 and Cluster3). The EAR file is uninstalled from WebSphere Application Server. The process removes all of the component versions from the IBM Urbancode Deploy inventory. The following screen capture shows the uninstall process running successfully:
This process was tested with IBM UrbanCode Deploy v184.108.40.206, the WebSphere Application Server – Deploy plug-in v86, and IBM WebSphere Application Server Network Deployment v8.5.5.