Tomcat-Maven 401 Error: Cannot invoke Tomcat manager

拟墨画扇 提交于 2019-12-03 19:28:23

问题


Went through most of the errors shown in StackOverFlow and still couldn't solve it. I'm trying to deploy a SpringMVC application. But, I just can't get it to work.

Maven Deploy Error:

[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:redeploy (default-cli) on project productmgmt: Cannot invoke Tomcat manager: Server returned HTTP response code: 401 for URL: http://localhost:8080/manager/text/deploy?path=%2Fproductmgmt&war=&update=true -> [Help 1]

Pom.xml:

<build>
        <finalName>productmgmt</finalName>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>tomcat-maven-plugin</artifactId>
                <configuration>
                    <url>http://localhost:8080/manager/text</url>
                    <path>/productmgmt</path>
                    <username>admin</username>
                    <password>password</password>
                </configuration>
            </plugin>
        </plugins>
    </build>

Tomcat-Users.xml

<role rolename="admin"/>
  <role rolename="manager"/>
  <user username="admin" password="admin" roles="admin,manager"/>
</tomcat-users>

More Information:

[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

This worked for me

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

回答1:


Your maven configuration has the username and password set as admin/password. In the Tomcat configuration they are set as admin/admin.

Switch your pom.xml to have <password>admin</password>.

Also, the roles need changing for the admin user as per the Tomcat docs. You'll want the manager-gui role to access the HTML manager and the manager-script role to access the text interface.



来源:https://stackoverflow.com/questions/12753578/tomcat-maven-401-error-cannot-invoke-tomcat-manager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!