Four easy steps on How to deploy the WAR file to vFabric TC 2.8.* server or Tomcat 7 remotely using Maven build (pom.xml)
Step 1: Open your tomcat-user.xml from your <CATALINA_HOME>/conf folder and insert the code:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<tomcat-users>
<role rolename="manager-gui" />
<role rolename="manage-script" />
<role rolename="manager-status" />
<role rolename="manager-jmx" />
<user username="adminuser" password="adminpwd" roles="manager-gui" />
</tomcat-users>
Note: Role name script, status and jmx are optional. In previous version of tomcat, you can use role "manager" but for tomcat 7, it was divided into four role. For depolyment, we need only "manager-gui".
Step 2: Update your Maven settings.xml with the following code. To check where is your maven settings located, just open a command prompt and type maven -X and it will show the global settings and user settings. I choose global settings since I will be allowing other users to use the same settings.
Open <MAVEN_HOME>/conf/settings.xml then insert the code:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<servers>
<server>
<id>remoteserver</id>
<username>adminuser</username>
<password>adminpwd</password>
</server>
</servers>
</settings>
Step 3: Open your pom.xml and insert the following code
Code:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<!-- for tomcat 6 -->
<!--
<artifactId>tomcat6-maven-plugin</artifactId>
-->
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<url>http://<remote_ip_address>:<port>/manager/html</url>
<server>remoteserver</server>
<path>/your_web_context_path_here</path>
</configuration>
</plugin>
Note: if you have a parent pom.xml you need to insert the following code to your parent pom.xml
Code:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
</plugin>
Step 4: Deploy or Redeploy
Run maven command to deploy
Code:
mvn tomcat7:deploy
For redeploy:
Code:
mvn tomcat7:redeploy
Step 1: Open your tomcat-user.xml from your <CATALINA_HOME>/conf folder and insert the code:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<tomcat-users>
<role rolename="manager-gui" />
<role rolename="manage-script" />
<role rolename="manager-status" />
<role rolename="manager-jmx" />
<user username="adminuser" password="adminpwd" roles="manager-gui" />
</tomcat-users>
Note: Role name script, status and jmx are optional. In previous version of tomcat, you can use role "manager" but for tomcat 7, it was divided into four role. For depolyment, we need only "manager-gui".
Step 2: Update your Maven settings.xml with the following code. To check where is your maven settings located, just open a command prompt and type maven -X and it will show the global settings and user settings. I choose global settings since I will be allowing other users to use the same settings.
Open <MAVEN_HOME>/conf/settings.xml then insert the code:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<servers>
<server>
<id>remoteserver</id>
<username>adminuser</username>
<password>adminpwd</password>
</server>
</servers>
</settings>
Step 3: Open your pom.xml and insert the following code
Code:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<!-- for tomcat 6 -->
<!--
<artifactId>tomcat6-maven-plugin</artifactId>
-->
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<url>http://<remote_ip_address>:<port>/manager/html</url>
<server>remoteserver</server>
<path>/your_web_context_path_here</path>
</configuration>
</plugin>
Note: if you have a parent pom.xml you need to insert the following code to your parent pom.xml
Code:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
</plugin>
Step 4: Deploy or Redeploy
Run maven command to deploy
Code:
mvn tomcat7:deploy
For redeploy:
Code:
mvn tomcat7:redeploy