Tomcat 8 integration with Maven

It seems that Eclipse (Kepler) does not have the proper plugin for Tomcat 8. I want to deploy my .war to Tomcat 8 and run it using the Maven pom.xml file. Can someone provide me with a walkthrough 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> 
+13
java eclipse maven tomcat war
Jun 17 '14 at 18:49
source share
4 answers

Can you use the pluygin load 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> 
+8
Jun 17 '14 at 19:35
source share
β€” -

An example of how to wage war with cargo and tomcat8

 mvn clean verify org.codehaus.cargo:cargo-maven2-plugin:run -Dcargo.maven.containerId=tomcat8x -Dcargo.maven.containerUrl=http://repo1.maven.org/maven2/org/apache/tomcat/tomcat/8.5.9/tomcat-8.5.9.zip 

If you want to add it to your pom

 <plugin> <groupId>org.codehaus.cargo</groupId> <artifactId>cargo-maven2-plugin</artifactId> <version>${cargo.version}</version> <configuration> <container> <containerId>tomcat8x</containerId> <zipUrlInstaller> <url>http://repo1.maven.org/maven2/org/apache/tomcat/tomcat/8.5.9/tomcat-8.5.9.zip</url> </zipUrlInstaller> </container> </configuration> </plugin> 

Then, to start a war (if your pom is war)

 mvn cargo:run 

To start from debugging (optional memory parameters)

 <plugin> <groupId>org.codehaus.cargo</groupId> <artifactId>cargo-maven2-plugin</artifactId> <version>${cargo.version}</version> <configuration> <container> <containerId>tomcat8x</containerId> <zipUrlInstaller> <url>http://repo1.maven.org/maven2/org/apache/tomcat/tomcat/8.5.9/tomcat-8.5.9.zip</url> </zipUrlInstaller> </container> <configuration> <properties> <!-- <cargo.servlet.port>8200</cargo.servlet.port> --> <cargo.jvmargs>-Xmx2048m -Xms512m</cargo.jvmargs> <cargo.start.jvmargs>-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000</cargo.start.jvmargs> </properties> </configuration> </configuration> </plugin> 

Then you need to create a remote debugging configuration in your IDE on port 8000 (the default port if nothing is specified)

Additional commands here: https://codehaus-cargo.imtqy.com/cargo/Maven2+plugin.html#Maven2plugin-TheCargoMavenpluginindetail

+3
Jan 20 '17 at 19:33
source share

For Tomcat 8, you must use load-maven2-plugin, which works for both maven 2 and maven 3. When configuring the plug-in for loading, make sure the value for the container Id is "tomcat8x". DO NOT omit the "x" after tomcat8.

+2
Jan 08 '15 at 16:59
source share

Just in case, you are using a separate local Tomcat server. If you use the built-in tomcat, this is not applicable.

In your pom.xml add the tomcat plugin. (You can use this for Tomcat 7 and 8):

pom.xml

 <!-- Tomcat plugin --> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <url>http:// localhost:8080/manager/text</url> <server>TomcatServer</server> *(From maven > settings.xml)* <username>*yourtomcatusername*</username> <password>*yourtomcatpassword*</password> </configuration> </plugin> 

users.xml-cat

 <tomcat-users> <role rolename="manager-gui"/> <role rolename="manager-script"/> <user username="admin" password="password" roles="manager-gui,manager-script" /> </tomcat-users> 

settings.xml (maven> conf)

 <servers> <server> <id>TomcatServer</id> <username>admin</username> <password>password</password> </server> </servers> 

* deployment / redeployment

mvn tomcat7: deploy OR mvn tomcat7: redeploy

Tried this (Both Ubuntu and Windows 8/10):
* Jdk 7 and Tomcat 7
* Jdk 7 and Tomcat 8
* Jdk 8 and Tomcat 7
* Jdk 8 and Tomcat 8

Tested on both Jdk 7/8 and Tomcat 7/8. (Works with Tomcat 8.5 Also, Tomcat 9 will be testing soon)

Note:
Tomcat Manager must be running or configured correctly before you can use it with maven.

+1
Sep 01 '17 at 15:15
source share



All Articles