I am having trouble in deploying to remote machine with tomcat installed as aservice. My tomcat-users is as follows:
<tomcat-users>
<role rolename="manager"/>
<user username="admin" password="admin" roles="tomcat, admin, manager-gui, manager-script"/>
</tomcat-users>
My settings.xml is:
<settings>
<pluginGroups>
<pluginGroup>org.apache.tomcat.maven</pluginGroup>
</pluginGroups>
<servers>
<server>
  <id>tomcat7</id>
  <username>admin</username>
  <password>admin</password>
</server>
</servers>
</settings>
And my pom.xml has the following:
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <configuration>
                    <server>tomcat7</server>
                    <url>http://localhost:8081/manager/text</url>
                    <warFile>target/editor-${project.version}.war</warFile>
                </configuration>
And I keep on getting the 401 Unauthorized on the output of maven console. Can you tell me what am I doing wrong?
The following way works for me.
Please change your pom.xml to include
<project>
    ...
    <build>    
        <plugins>    
        ....
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <url>http://localhost:8080/manager/text</url>
                    <server>my-tomcat</server>
                    <path>/myapp</path>
                </configuration>
            </plugin>
        </plugins>
        ...
    </build>
    ...
</project>
Make sure your Tomcat 7 server have the following lines on TOMCAT_HOME/conf/tomcat-users.xml:
<!-- Role to manage WAR files via HTML /manager. The name should be as is! -->
<role rolename="manager-gui"/>
<!-- Role to manage WAR files via script like Maven. The name should be as is! -->
<role rolename="manager-script"/>
<!-- One user cannot have manager-gui and manager-script roles -->
<user username="managerGui" password="managerPwd" roles="manager-gui"/>
<user username="manager" password="managerPwd" roles="manager-script"/>
Configure your USER_HOME/.m2/settings.xml to include the password.
<settings>
    ...
    <servers>
        ...
        <server>
            <id>my-tomcat</id>
            <username>manager</username>
            <password>managerPwd</password>
        </server>
    </servers>
</settings>
Deploy using mvn tomcat7:redeploy
Read more on http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With