Tomcat 8 integration with Maven

Débora picture Débora · Jun 17, 2014 · Viewed 39.8k times · Source

It sounds like Eclipse (Kepler) does not have a proper plugin for Tomcat 8. I want to deploy my .war into Tomcat 8 and run it by Maven pom.xml file. Can anyone provide me step-by-step guidance or any resources, please?

My POM file:

<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>
  <groupId>Test-App</groupId>
  <artifactId>test-rest</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>test-rest Maven Webapp</name>
  <url>http://maven.apache.org</url>
     <!-- Tomcat plugin -->


  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
  <plugins>
  <plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
     <path>/${project.build.finalName}</path>
     <update>true</update>
     <url>http:// localhost:8080/manager/text</url>
     <username>tomcat</username>
     <password>tomcatuser</password>
    </configuration>
   </plugin>
   </plugins>
    <finalName>test-rest</finalName>
  </build>
</project>

Answer

NimChimpsky picture NimChimpsky · Jun 17, 2014

Can you use the cargo pluygin instead, this works for me, deploying to tomcat8 :

             <plugin>
                <groupId>org.codehaus.cargo</groupId>
                <artifactId>cargo-maven2-plugin</artifactId>
                <version>1.4.8</version>
                <configuration>
                    <container>
                        <containerId>tomcat8x</containerId>
                        <home>${env.CATALINA_HOME}</home>
                    </container>
                    <configuration>
                        <type>existing</type>
                        <home>${env.CATALINA_HOME}</home>
                    </configuration>
                    <deployables>
                        <deployable>
                            <groupId>com.yourcompany</groupId>
                            <artifactId>ROOT</artifactId>
                            <type>war</type>
                            <properties>
                                <context>${project.build.finalName}</context>
                            </properties>
                        </deployable>
                    </deployables>
                    <deployer>
                        <type>installed</type>
                    </deployer>
                </configuration>
            </plugin>