Search code examples
maventomcatmaven-tomcat-plugin

tomcat-maven-plugin 403 error


When I use mvn tomcat:deploy of tomcat-maven-plugin there is a 403 error:

Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.0:deploy (default-cli) on project my-webapp: Cannot invoke Tomcat manager: Server returned HTTP response code: 403 for URL: http://localhost:8080/manager/text/deploy?path=%2Fdms&war=

I think it because of null war parameter. But why is it null???

In pom.xml there is:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>tomcat-maven-plugin</artifactId>

  <configuration>
    <warFile>target\my-webapp.war</warFile>
    <server>myserver</server>
    <url>http://localhost:8080/manager/text</url>
    <path>/dms</path>
  </configuration>
</plugin>

Solution

  • The /manager application is by default secured by username/password. If you enter http://localhost:8080/manager you will be asked to provide security credentials as well. First create/enable user in Tomcat: after canceling or few unsuccessful attempts Tomcat will provide help on error screen. Then use these credentials in tomcat-maven-plugin as explained here:

    Add a plugin configuration block to your pom.xml:

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>tomcat-maven-plugin</artifactId>
        <configuration>
                <server>myserver</server>
        </configuration>
    </plugin>
    

    Add a corresponding server block to your settings.xml:

    <server>
        <id>myserver</id>
        <username>myusername</username>
        <password>mypassword</password>
    </server>