Error 403 when try to deploy a maven project with tomcat-maven-plugin

I am trying deploy my project to tomcat7 using the Eclipse IDE, and I facing this error:

Uploading: http://localhost:8080/manager/html/deploy?path=%2Fexample
Uploaded: http://localhost:8080/manager/html/deploy?path=%2Fexample (13855 KB at 61573.5 KB/sec)

[ERROR] Tomcat return http status error: 403, Reason Phrase: Forbidden
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.259s
[INFO] Finished at: Sun Apr 20 09:44:18 GMT-03:00 2014
[INFO] Final Memory: 13M/223M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy (default-cli) on project example: Tomcat return http status error: 403, Reason Phrase: Forbidden: <html><head><title>Apache Tomcat/7.0.50 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 403 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>Access to the specified resource has been forbidden.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.50</h3></body></html> -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

My pom.xml have this configuration:

  <build>
  <plugins>
            <plugin>
              <groupId>org.apache.tomcat.maven</groupId>
              <artifactId>tomcat7-maven-plugin</artifactId>
              <version>2.2</version>
              <configuration>
                  <url>http://localhost:8080/manager/html</url>
                  <server>TomcatServer</server>
                  <path>/example</path>
                  <username>klebermo</username>
                  <password>[password]</password>
              </configuration>
            </plugin>
    </plugins>
    </build>

My tomcat-users.xml is that:

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
  <role rolename="manager"/>
  <role rolename="admin"/>
  <user username="klebermo" password="[password]" roles="admin,manager"/>
</tomcat-users>

Anyone can point me what I doing wrong?

the documentation mentions that the remote deployment commands should be sent to url manager/text, see here in Deploy A New Application Remotely.

by changing the configuration to that url instead, it should work:

<configuration>
    <url>http://localhost:8080/manager/text</url>
    ...
</configuration>

Also Tomcat has several pre-defined roles for doing certain tasks, try adding role manager-script:

<tomcat-users>
  <user username="tomcat" password="[password]" 
       roles="admin,manager,manager-script"/>
</tomcat-users>

got 403 when trying to deploy war to tomcat with maven, I found the solution. I used the wrong goal. Correct would have been. mvn tomcat7:deploy instead of tomcat:deploy (target definitions of plugin). By devining that  I'm trying to automatically deploy a Maven webapp from Eclipse Java EE to my local Tomcat server. I'm using Windows XP. This is the error: [ERROR] Failed to execute goal org.codehaus.mojo:tomcat-m

I changed the Server location configuration of the tomcat within the eclipse configuration panel. In this way eclipse uses directly the configuration of your tomcat installation instead of the workspace metadata. After conducting all steps according to this question and similar questions and answers this step finally solved the problem for me. Problem prerequesites: Eclipse Luna, Maven 3.1, Dynamic-Web-Project, maven-war-plugin, tomcat 7

Following picture shows the appropriate configuration which worked for me and solved the same problem of OP.

tomcat-maven-plugin 403 error - maven - html, When I use mvn tomcat:deploy of tomcat-maven-plugin there is a 403 error: project my-webapp: Cannot invoke Tomcat manager: Server returned HTTP after canceling or few unsuccessful attempts Tomcat will provide help on error screen. Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question.Provide details and share your research! But avoid …. Asking for help, clarification, or responding to other answers.

The underlying cause for me was leaving out a designated "manager-script" role user in tomcat-users.xml

<role rolename="manager-gui"/>
  <role rolename="manager-script"/>
  <!-- <user username="tomcatadmin" password="s3cret" roles="manager-gui"/> -->
  <user username="tcat-gui" password="asdf" roles="manager-gui"/>
    <user username="tcat-script" password="psswrd" roles="manager-script"/>

So in addition to designating a manager-script role you need to create an actual manager-script user and this is the user you plug into the Web-apps POM. My environment is IntelliJ and Maven project.

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.3-SNAPSHOT</version>
                <configuration>
                    <url>http://localhost:8080/manager/text</url>
                    <server>TomcatServer</server>
                    <username>tcat-script</username>
                    <password>psswrd</password>
                </configuration>
            </plugin>
        </plugins>
    </build>

Good luck!

maven tomcat7 plugin authentication fail, 403 Forbidden, I try and try because I felt guilty of posting this because there are thread similar to this. When I use mvn tomcat:deploy of tomcat-maven-plugin there is a 403 error​: org.codehaus.mojo:tomcat-maven-plugin:1.0:deploy (default-cli) on project  I have configured the tomcat7-maven-plugin to deploy the war under my tomcat server. but its keep on getting failed. i am sure i have valid configuration on my pom.xml and tomcat-user.xml

Unable to deply Maven Webapplication in Tomcat Eclipse. (IDEs , You can then deploy maven web app projects to Tomcat without any problems. (If you got 403-Forbidden error ) Then you need to allow the eclipse to -403-​when-try-to-deploy-a-maven-project-with-tomcat-maven-plugin). After you create a maven project in eclipse for spring application development, you always need to use maven to clean, build, install and deploy the spring application to a tomcat server to see the result. This article will tell you how to deploy a maven eclipse project to tomcat. 1. Create Maven Project in STS ( Spring Tool Suite ).

[PDF] Maven Deploy Error Code 403 Forbidden, Error 403 when try to deploy a maven project with tomcat-maven-plugin. I am trying deploy my project to tomcat7 using the Eclipse IDE, and I facing this error:  1. Tomcat 7 Example. This example shows you how to package and deploy a WAR file on Tomcat 7. 1.1 Tomcat Authentication Add an user with roles manager-gui and manager-script.

How to deploy Maven based war file to Tomcat, following error: Tomcat return http status error: 403,. Reason Phrase: When I try to deploy to Heroku using this guide I get the following error Hello, after importing maven project: - In adminui - pom.xml : " Plugin An error has occurred in. warFile – The path of the WAR file to deploy. Run application with tomcat plugin. To run the application with tomcat maven plugin, use maven goal as – mvn tomcat7:run. When you run above maven goal, you can see tomcat starting in console log with default port 8080.

Comments
  • Ok, I did this. My current problem is that somehow when I start the tomcat (via eclipse) the file tomcat-users.xml is redefined, and the data I insert in the file are lost. When I reopen this file after I have started the tomcat, the content of the file is completely different from what I have saved.
  • check the Servers section in your explorer tree, those are the tomcat files that overwrite the server on each deployment. try to edit those directly.