I am trying to do mvn clean package tomcat7:deploy
but always I get this error: tomcatManager status code:403, ReasonPhrase:Forbbiden
My config
Enough to do like this
pom.xml
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<path>/mywebapp</path>
<update>true</update>
<url>http://localhost:8080/manager/text</url>
<username>tomcat</username>
<password>tomcat</password>
</configuration>
</plugin>
tomcat-users.xml
<tomcat-users>
<role rolename="tomcat"/>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="admin-gui"/>
<user username="tomcat" password="tomcat" roles="tomcat,manager-gui,admin-gui,manager-script"/>
</tomcat-users>
From http://tomcat.apache.org/maven-plugin-2.0/index.html
Use http://localhost:8080/manager/text rather than the default tomcat6 url.
This error will also appear if the same WAR with the same name has already been deployed to tomcat.
There is some misunderstanding about role name and the last part of the URL:
Originally in tomcat-usres.xml there was only "tomcat" user (role tomcat), user "both" (tomcat + role1) but no admin role. It seems that the last part of the URL equals to role name in some aspect ...
This worked for me (otherwise I always got 403 even provided correct user + password):
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="tomcat"/>
<role rolename="admin"/>
<user username="tomcat" password="tomcat" roles="admin,tomcat"/>
<user username="admin" password="tomcat" roles="admin,tomcat"/>
</tomcat-users>
Url is not correct use:
<tomcat-url>http://localhost:8080/manager/html</tomcat-url>
Wanted to add this as a comment, but do not have enough reputation score to do so.
Adding this as an answer as it may be helpful for someone. I was getting the exactly same errors while trying to deploy on tomcat7 using eclipse, and was still not working after trying above solutions. finally I tried outside eclipse using commandline(cmd) and it worked like a charm. obviously I needed to install maven on my machine and then set M2_Home user variable and path variable pointing to M2_HOME/bin.
Thanks.
I had same problem. But I found following solution of this problem:
pom.xml
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<server>localhost</server>
<path>/${project.build.finalName}</path>
</configuration>
</plugin>
~/.m2/settings.xml
<servers>
<server>
<id>localhost</id>
<username>admin</username>
<password>s3cret</password>
</server>
tomcat-users.xml
<role rolename="manager-script"/>
<user username="admin" password="s3cret" roles="manager-script"/>
After changing tomcat-users.xml do not forget to restart the server. Also do not assign the manager-gui role with the manager-script to the same user.