Is the tomcat7-maven-plugin
working with a tomcat 8 server and java 8? I can't find any tomcat8-maven-plugin
.

- 303,325
- 100
- 852
- 1,154

- 4,385
- 8
- 40
- 61
-
1Unfortunately it is not ready https://issues.apache.org/jira/browse/MTOMCAT-234 – Gilberto Dec 30 '16 at 12:51
-
1Try using Cargo See answer : http://stackoverflow.com/questions/24271213/tomcat-8-integration-with-maven/41771077#41771077 – Ronan Quillevere Jan 20 '17 at 19:56
-
Could you explain what you mean in Tomcat7-maven-plugin working with a tomcat 8 server? how you make plugin to work with stand-alone server? plugin starts its own server.. – Giorgi Tsiklauri Apr 18 '19 at 09:55
-
Does this answer your question? [Tomcat 8 integration with Maven](https://stackoverflow.com/questions/24271213/tomcat-8-integration-with-maven) – OhadR Feb 11 '20 at 20:20
6 Answers
Yes you can,
In your pom.xml
, add the tomcat plugin. (You can use this for both 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>
tomcat-users.xml
<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>
*** deploy/re-deploy**
mvn tomcat7:deploy
OR
mvn tomcat7:redeploy
Tried this on (Both Ubuntu and Windows 8/10):
- Jdk 7 & Tomcat 7
- Jdk 7 & Tomcat 8
- Jdk 8 & Tomcat 7
- Jdk 8 & Tomcat 8
- Jdk 8 & Tomcat 9
Tested on Both Jdk 7/8 & Tomcat 7/8. (Works with Tomcat 8.5 and 9)
Note:
Tomcat manager should be running or properly setup, before you can use it with maven.
Good Luck!

- 6,075
- 12
- 66
- 96

- 1,960
- 5
- 27
- 42
-
> mvn org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:run INFO: Starting Servlet Engine: Apache Tomcat/7.0.47 – Grigory Kislin Jul 06 '16 at 13:38
-
9that's nice only if you have tomcat on your local PC. Doesn't solve the problem for embedded tomcat – long Aug 29 '16 at 08:34
-
8Putting the username and password in the POM is redundant and a security risk (especially if you check your code into a repository). The whole point of identifying the server by ID in the POM is so that Maven can look up the username and password in the user-specific settings file (not checked into source control). But otherwise this post was really helpful---thanks. – Garret Wilson Oct 28 '16 at 02:49
-
tomcat7-maven-plugin, what does 7 stands for? Is it java version or tomcat version. Can I use tomcat7-maven-plugin with Tomcat-9? – Kuldeep Yadav Dec 26 '16 at 05:41
-
2Where can I find the following files: tomcat-users.xml - (PROJECT_NAME\target\tomcat\conf\tomcat-users.xml?), settings.xml - (???). I have maven project but still can't figure it out – Benas Apr 20 '17 at 11:42
-
In this solution, it uses a separate apache tomcat installed and you can find in the location or path where you installed tomcat (or extracted if coming from a zip or tar.gz file). For example, C:\apache-tomcat-8\conf\tomcat-users.xml. If you are in ubuntu... example would be /opt/tomcat/conf/tomcat-users.xml – Borgy Manotoy Apr 20 '17 at 12:01
-
-
I just did and it works... just note that when you update maven, you might lose the old configuration. Goodluck! – Borgy Manotoy Oct 28 '17 at 08:15
-
Is it possible that I deploy my app with the plugin only without the tomcat server installed? – Drake .C Jun 21 '19 at 00:28
-
Yes it is possible, but I am not sure if it is advisable to deploy/run the application with just plugin, when in production mode. – Borgy Manotoy Jun 25 '19 at 11:42
Plugin run Tomcat 7.0.47:
mvn org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:run
...
INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
This is sample to run plugin with Tomcat 8 and Java 8: Cargo embedded tomcat: custom context.xml

- 1
- 1

- 16,647
- 10
- 125
- 197
Almost 2 years later....
This github project readme has a some clarity of configuration of the maven plugin and it seems, according to this apache github project, the plugin itself will materialise soon enough.

- 6,986
- 16
- 73
- 121
-
linking my answer through this url http://stackoverflow.com/questions/37370927/jenkins-deploy-war-file-to-tomcat-8 – Praveen Kumar K S Sep 10 '16 at 04:40
Since November 2017, one can use tomcat8-maven-plugin:
<!-- https://mvnrepository.com/artifact/org.apache.tomcat.maven/tomcat8-maven-plugin -->
<dependency>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat8-maven-plugin</artifactId>
<version>2.2</version>
</dependency>
Note that this plugin resides in ICM repo (not in Maven Central), hence you should add the repo to your pluginsRepositories in your pom.xml:
<pluginRepositories>
<pluginRepository>
<id>icm</id>
<name>Spring Framework Milestone Repository</name>
<url>http://maven.icm.edu.pl/artifactory/repo</url>
</pluginRepository>
</pluginRepositories>

- 8,276
- 3
- 47
- 53
-
3tried but saw `Could not transfer artifact org.apache.tomcat.maven:tomcat8-maven-plugin:pom:2.2 from/to icm (http://maven.icm.edu.pl/artifactory/repo): Authentication failed for http://maven.icm.edu.pl/artifactory/repo/org/apache/tomcat/maven/tomcat8-maven-plugin/2.2/tomcat8-maven-plugin-2.2.pom 401 Unauthorized` – Hawk Oct 20 '21 at 05:05
-
Moreover, it is not secure to download anything on your laptop from third-party like http://maven.icm.edu.pl/artifactory – Sergio Kosik Jul 22 '22 at 08:53
An other solution (if possible) would be to use TomEE instead of Tomcat, which has a working maven plugin:
<plugin>
<groupId>org.apache.tomee.maven</groupId>
<artifactId>tomee-maven-plugin</artifactId>
<version>7.1.1</version>
</plugin>
Version 7.1.1 wraps a Tomcat 8.5.41

- 1,969
- 2
- 22
- 47
groupId and Mojo name change Since version 2.0-beta-1 tomcat mojos has been renamed to tomcat6 and tomcat7 with the same goals.
You must configure your pom to use this new groupId:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<version>2.3-SNAPSHOT</version>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.3-SNAPSHOT</version>
</plugin>
</plugins>
</pluginManagement>
Or add the groupId in your settings.xml
.... org.apache.tomcat.maven ....

- 27
- 4