After a long googling, I didn't find how to do auto deploy for webshpere application using maven. Finally I have done successfully.
Here is the pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>testwasEar</artifactId>
<groupId>com.mycompany</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.mycompany</groupId>
<artifactId>testwasEar-ear</artifactId>
<packaging>ear</packaging>
<version>1.0-SNAPSHOT</version>
<name>testwasEar-ear JEE5 Assembly</name>
<url>http://maven.apache.org</url>
<properties>
<was6Home>C:\IBM\WebSphere\AppServer1</was6Home>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<version>5</version>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>was6-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<goals>
<goal>wsDefaultBindings</goal>
<goal>wsListApps</goal>
<goal>installApp</goal>
</goals>
</execution>
</executions>
<configuration>
<wasHome>${was6Home}</wasHome>
<conntype>SOAP</conntype>
<host>localhost</host>
<port>8880</port>
<profileName>AppSrv02</profileName>
<verbose>true</verbose>
<user>admin</user>
<password>admin</password>
<username>admin</username>
<earFile>target\testwasEar-ear.ear</earFile>
<updateExisting>false</updateExisting> <!-- this needs to be false as we're reinstalling each time -->
<applicationName>MobileWeb</applicationName>
</configuration>
</plugin>
</plugins>
<finalName>testwasEar-ear</finalName>
</build>
<dependencies>
<!--dependency>
<groupId>com.mycompany</groupId>
<artifactId>testwas-web</artifactId>
<version>1.0-SNAPSHOT</version>
<type>war</type>
</dependency -->
<dependency>
<groupId>com.mycompany.testweb</groupId>
<artifactId>TestWeb</artifactId>
<version>trunk-SNAPSHOT</version>
<type>war</type>
</dependency>
</dependencies>
</project>
Run maven goals like below:
Note:
We can't deploy only WAR, need to have EAR.
Here is the pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>testwasEar</artifactId>
<groupId>com.mycompany</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.mycompany</groupId>
<artifactId>testwasEar-ear</artifactId>
<packaging>ear</packaging>
<version>1.0-SNAPSHOT</version>
<name>testwasEar-ear JEE5 Assembly</name>
<url>http://maven.apache.org</url>
<properties>
<was6Home>C:\IBM\WebSphere\AppServer1</was6Home>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<version>5</version>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>was6-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<goals>
<goal>wsDefaultBindings</goal>
<goal>wsListApps</goal>
<goal>installApp</goal>
</goals>
</execution>
</executions>
<configuration>
<wasHome>${was6Home}</wasHome>
<conntype>SOAP</conntype>
<host>localhost</host>
<port>8880</port>
<profileName>AppSrv02</profileName>
<verbose>true</verbose>
<user>admin</user>
<password>admin</password>
<username>admin</username>
<earFile>target\testwasEar-ear.ear</earFile>
<updateExisting>false</updateExisting> <!-- this needs to be false as we're reinstalling each time -->
<applicationName>MobileWeb</applicationName>
</configuration>
</plugin>
</plugins>
<finalName>testwasEar-ear</finalName>
</build>
<dependencies>
<!--dependency>
<groupId>com.mycompany</groupId>
<artifactId>testwas-web</artifactId>
<version>1.0-SNAPSHOT</version>
<type>war</type>
</dependency -->
<dependency>
<groupId>com.mycompany.testweb</groupId>
<artifactId>TestWeb</artifactId>
<version>trunk-SNAPSHOT</version>
<type>war</type>
</dependency>
</dependencies>
</project>
Run maven goals like below:
mvn clean install was6:wsDefaultBindings was6:wsUninstallApp was6:installApp was6:wsStartApp
clean --> clean the project
install --> build the project
was6:wsDefaultBindings --> before install app this must to call, will create default files and bindings for WASwas6:wsUninstallApp --> If we need to install a fresh application, call this before install the applicationwas6:installApp --> this will install applicationwas6:wsStartApp --> installApp will only do installation and not start the application. After successfully installed we need to call this.
Note:
We can't deploy only WAR, need to have EAR.
hi , have you tried deploying ear to WAS ND from a remote machine - say build server? I am having hard time in deploying the ear to remote server where i need to mention cluster name and server name in the configuration.
ReplyDeleteThis comment has been removed by the author.
ReplyDelete