- Introduction
- How It Works
- Goal-
deploy
- Single Target Server
- Multi Target Servers
- Pre-Steps and Post-Steps
- Customized Jython Script File
- Continues Deployment with Jenkins
- With Global Security Turned on
- Change List
Maven plugin to deploy a single war or ear to one or multi local or remote WebSphere Application Server (WAS) at a single build.
Tested on WAS 8.5
Requires: WebSphere Application Server installation on host box! But no need to be configured, nor running.
Requires: JDK 6 or later
These are the known popular ways that you can programmly have your war/ear deployed to a running WebSphere Application Server:
Using IBM specialized JMX APIs you could not only retrieve the information of the apps, but also you can do deployment.
2 jars from WebSphere are required along with your build.
- com.ibm.ws.admin.client_x.x.x.jar (over 50MB)
- com.ibm.ws.orb_x.x.x.jar (about 2MB)
It does NOT support all options for deployment!
Deployment by adding your packages to a monitoredDeployableApps
subdirectory of an application server or deployment manager profile.
For more information, please check: http://www-01.ibm.com/support/knowledgecenter/SSAW57_8.5.5/com.ibm.websphere.nd.doc/ae/trun_app_install_dragdrop.html
In order to deploy to a remote WAS, you'll have to copy/upload your packages to remote host first thru sftp or other approaches.
It's turned off by default.
WebSphere provides a set of built-in ant tasks, by using which you could also programmly have your packages deployed to WAS.
Ant tasks are in the end been translated to jacl
script and been executed in wsadmin
client.
wsadmin client tool is the most powerful and flexible tool from OPS' perspective, which locates in $WAS_HOME/bin/wsadmin.sh
.
It supports 2 scripting languages: jacl (default) and jython (recommended).
It uses WebSphere built-in security (credencials) and file transfer protocal (no sftp is needed) for a remote deployment.
JMX and Ant Tasks approaches were also implemented in the beginning, but we had them removed before 1.0.2
The only goal of this plugin, it will:
- Check if an application with the same name already installed on target server(s)/cluster(s)
- Uninstall it if yes
- Install the package to target server(s)/cluster(s)
- Restart target server(s)/cluster(s)
Name | Type | Description |
---|---|---|
wasHome | String | WebSphere Application Server home. Default: ${env.WAS_HOME} , required |
applicationName | String | Application name displayed in admin console. Default: ${project.build.finalName} |
applicationNameSuffix | String | Will be appended to applicationName, as applicationName_applicationNameSuffix , property file only |
host | String | Local/Remote WAS IP/domain URL. e.g. 10.95.0.100 , devtrunk01.company.com , default: localhost |
port | String | Default: 8879 (when cluster not empty); 8880 (when cluster empty) |
connectorType | String | Default: SOAP |
cluster | String | Target cluster name, required if target WAS is a cluster |
cell | String | Target cell name |
node | String | Target node name, |
server | String | Target server name, |
webservers | String | Target web server(s) name, comma-separated. |
virtualHost | String | Target virtual host name |
user | String | Account username for target WAS admin console, if global security is turned on |
password | String | Account password for target WAS admin console, if global security is turned on |
contextRoot | String | required for war deployment |
sharedLibs | String | Bind the exist shared libs to ear/war, comma-separated (,) |
parentLast | Boolean | true to set classloader mode of application to PARENT_LAST , default false |
restartAfterDeploy | Boolean | true to restart server after deploy, false to start application directly. Default true |
webModuleParentLast | Boolean | true to set classloader mode of web module to PARENT_LAST , default false |
packageFile | String | The EAR/WAR package that will be deployed to remote RAS, Default: ${project.artifact.file} |
failOnError | Boolean | Default: false Whether failed the build when failed to deploy. |
verbose | Boolean | Whether show more detailed info in log |
script | String | Your own jython script for deployment. Double braces for variables, such as: {{cluster}} |
scriptArgs | String | Args that will be passed to the script |
javaoption | String | Sample -Xmx1024m , -Xms512m -Xmx1024m |
deployOptions | String | Sample -precompileJSPs , -precompileJSPs -deployws |
preSteps | Ant tasks | Ant tasks that can be executed before the deployments |
postSteps | Ant tasks | Ant tasks that can be executed after the deployments |
deploymentsPropertyFile | File | For multi target, hold above parameters, except those in bold. Default: was-maven-plugin.properties |
Generally, you need to specify at least
cluster
for a clusterserver
andnode
for a non-cluster
<plugin>
<groupId>com.orctom.mojo</groupId>
<artifactId>was-maven-plugin</artifactId>
<version>${latest-version}</version>
<executions>
<execution>
<id>deploy</id>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<wasHome>${env.WAS_HOME}</wasHome>
<applicationName>${project.build.finalName}</applicationName>
<host>localhost</host>
<server>server01</server>
<node>node01</node>
<virtualHost>default_host</virtualHost>
<verbose>true</verbose>
</configuration>
</execution>
</executions>
</plugin>
This property file contains the meta config for target WAS.
The section name will be used to identify each target WAS.
Please put was-maven-plugin.properties
to the same folder as pom.xml
, to make it available as ${project.basedir}/was-maven-plugin.properties
[DEFAULT]
virtualHost=default_host
[dev-trunk1]
host=devtrunk1.company.com
applicationNameSuffix=trunk1
cluster=cluster01
server=server01
[dev-trunk2]
host=devtrunk2.company.com
applicationNameSuffix=trunk2
cluster=cluster02
server=server02
[dev-trunk3]
host=devtrunk3.company.com
applicationNameSuffix=trunk3
cluster=cluster03
server=server03
virtualHost=devtrunk3_host
<plugin>
<groupId>com.orctom.mojo</groupId>
<artifactId>was-maven-plugin</artifactId>
<version>${latest-version}</version>
<executions>
<execution>
<id>deploy</id>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<wasHome>${env.WAS_HOME}</wasHome>
<verbose>true</verbose>
</configuration>
</execution>
</executions>
</plugin>
Deploy to dev-trunk1
and dev-trunk2
mvn clean install -Ddeploy_targets=`dev-trunk1`,`dev-trunk2`
Deploy to dev-trunk2
and dev-trunk3
mvn clean install -Ddeploy_targets=`dev-trunk2`,`dev-trunk3`
<plugin>
<groupId>com.orctom.mojo</groupId>
<artifactId>was-maven-plugin</artifactId>
<version>${latest-version}</version>
<executions>
<execution>
<id>deploy</id>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<wasHome>${env.WAS_HOME}</wasHome>
<verbose>true</verbose>
<preSteps>
<target name="pre 1">
<echo message="====== pre 1 ===== ${applicationName}" />
</target>
<target name="pre 2">
<echo message="====== pre 2 =====" />
</target>
</preSteps>
<postSteps>
<target name="post 1">
<echo message="====== post 1 =====" />
</target>
<target name="post 2">
<echo message="====== post 2 =====" />
<sleep seconds="10"/>
</target>
</postSteps>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>20020829</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.8.4</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.49</version>
</dependency>
</dependencies>
</plugin>
- pre-steps/post-steps can be used with both single target server and multi target servers
- All properties defined in properties section of pom or in was-maven-plugin.properties are available in pre-steps/post-steps ant tasks
This plugin also supports customized jython script if you need to tween the installation options, such server mappings.
You can copy-create it from the built-in one, or write a totally different one of you own.
Double braces for variables, such as: {{cluster}}
, properties in was-maven-plugin.properties are all available as variables.
<plugin>
<groupId>com.orctom.mojo</groupId>
<artifactId>was-maven-plugin</artifactId>
<version>${latest-version}</version>
<executions>
<execution>
<id>deploy</id>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<wasHome>${env.WAS_HOME}</wasHome>
<script>your-jython-script.py</script><!-- relative path to project root, or absolute path starts with a "/" (Linux) or "\" (Windows) -->
<scriptArgs>optional-args</scriptArgs><!-- "-o deploy" will be appended if not specified. -->
<verbose>true</verbose>
</configuration>
</execution>
</executions>
</plugin>
We could move this plugin to a profile, and utilize Extended Choice Parameter plugin to make this parameterized.
<profiles>
<profile>
<id>deploy</id>
<activation>
<property>
<name>deploy</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.orctom.mojo</groupId>
<artifactId>was-maven-plugin</artifactId>
<version>${latest-version}</version>
<executions>
<execution>
<id>deploy</id>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<wasHome>${env.WAS_HOME}</wasHome>
<verbose>true</verbose>
<preSteps>
<target name="unzip-Config-zip">
<echo message="Unzipping ${project.build.directory}/Config.zip --> WAS shared libs folder" />
<unzip dest="${WAS shared libs folder}/conf">
<fileset dir="${project.build.directory}/">
<include name="Config.zip" />
</fileset>
</unzip>
</target>
<target name="unzip-static-zip">
<taskdef resource="net/sf/antcontrib/antcontrib.properties" />
<if>
<available file="${project.build.directory}/static.zip" />
<then>
<echo message="Unzipping ${project.build.directory}/static.zip --> apache sratic path" />
<unzip dest="${apache sratic path}" src="${project.build.directory}/static.zip" />
</then>
</if>
</target>
<target name="copy-config-to-remote">
<taskdef resource="net/sf/antcontrib/antcontrib.properties" />
<if>
<isset property="some property name in pom or was-maven-plugin/properties" />
<then>
<echo message="Coping ${WAS shared libs folder}/conf to ${remote ip}:${WAS shared libs folder}/conf ..." />
<scp todir="wsadmin@${remote ip}:${WAS shared libs folder}/conf" keyfile="${user.home}/.ssh/id_rsa" trust="true" failonerror="false">
<fileset dir="${WAS shared libs folder}/conf" />
</scp>
<echo message="Copied ${meta.config.path}/conf" />
</then>
<else>
<echo message="Skipped, not needed." />
</else>
</if>
</target>
</preSteps>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>20020829</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.8.4</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.49</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Configure
Trigger
When Global Security is enabled on remote WAS (not under a same deployment manager), certificates of remote WAS need to be added to local trust store. We could configure WAS to prompt to add them to local trust store.
- Open ${WAS_HOME}/properties/ssl.client.props
- Change the value of
com.ibm.ssl.enableSignerExchangePrompt
togui
orstdin
gui
: will prompt a Java based window, this requires a X window installed.stdin
: when using ssh, or on client linux without X window installed.
- Fixed issue of not starting application on standalone WAS (restartAfterDeploy=false)
- Fixed server mapping issue with cluster. Apps will be deployed to all servers that managed by the specified cluster.
- Web servers support, use
webservers
to specify the web server(s) that you want to bind. (but you still have to 'update web server plug-in configuration' by your self.) - Added parameter
deployOptions
, expecting space-separated options such as-precompileJSPs -deployws
, which will be prepended in the deployment options. - Fixed issue about
failOnError
. - Extracted some common code including
websphere.py
to was-util, which is also been used by was-gradle-plugin
- Fixed the issue about "Template 'jython\websphere.py' not found" specific for Windows.
- Fixed the issue with customized script.
- Added a boolean parameter
restartAfterDeploy
:true
to restart server after deployfalse
to start application directly- Default:
true
- Added support to override default
javaoption
in wsadmin client, in case you getOutOfMemoryError
.
- Fixed single target WAS deployment issue.
- Not to check whether parent folder of deployment script been created or not.
- Removed
preCompileJSPs
options for deployment.
- Fixed multi-server deployment issue.
- Downgraded to use 1.5 build level, so that it can be used for older version of websphere.
- Fixed property resolving issue, properties in was-maven-plugin.properties are all available in custome scripts and pre/post steps.
- Added
PARENT_LAST
for application and web module andshared libs
bindings. - Added
failonerror
- Removed private project specific logic. (it's the 1st working version for general projects for websphere deployment).