3

在这个问题上需要你的帮助。我正在尝试使用tomcat7.maven插件版本2.1脚本通过eclipse在localhost:8080部署war文件,但总是收到401未经授权的错误。我的 PC 操作系统是 windows 7 64 位。

这是我的POM:

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <configuration>
        <url>http://localhost:8080/manager/text</url>
        <server>localhost</server>
        <username>tomcat</username>
        <password>tomcat</password>
        <path>/${project.build.finalName}</path>    
        <warDirectory>${project.build.directory}/exploded/${project.build.finalName}.war</warDirectory>
        <update>true</update>    
     </configuration>
    <version>2.1</version>
  </plugin>

这是我的 tomcat-users.xml :

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

这是我在 /.M2 目录中的 settings.xml。

<settings>
    <servers>
        <server>
          <id>localhost</id>
          <username>tomcat</username>
          <password>tomcat</password>
        </server>
    </servers>
</settings>

这是我的日志文件输出:

[DEBUG] Configuring mojo org.apache.tomcat.maven:tomcat7-maven-plugin:2.1:deploy from plugin realm ClassRealm[plugin>org.apache.tomcat.maven:tomcat7-maven-plugin:2.1, parent: sun.misc.Launcher$AppClassLoader@5d4177f3]
[DEBUG] Configuring mojo 'org.apache.tomcat.maven:tomcat7-maven-plugin:2.1:deploy' with basic configurator -->
[DEBUG]   (f) charset = ISO-8859-1
[DEBUG]   (f) contextFile = C:\java\Spring3HibernateMaven\target\Spring3HibernateMaven-0.0.1-SNAPSHOT\META-INF\context.xml
[DEBUG]   (f) ignorePackaging = false
[DEBUG]   (f) mode = war
[DEBUG]   (f) packaging = war
[DEBUG]   (f) password = tomcat
[DEBUG]   (f) path = /Spring3HibernateMaven-0.0.1-SNAPSHOT
[DEBUG]   (f) server = localhost
[DEBUG]   (f) update = true
[DEBUG]   (f) url = http://localhost:8080/manager/text
[DEBUG]   (f) username = tomcat
[DEBUG]   (f) version = 2.1
[DEBUG]   (f) warFile = C:\java\Spring3HibernateMaven\target\Spring3HibernateMaven-0.0.1-SNAPSHOT.war
[DEBUG] -- end configuration --
[INFO] Deploying war to http://localhost:8080/Spring3HibernateMaven-0.0.1-SNAPSHOT  
[DEBUG] Connection request: [route: {}->http://localhost:8080][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 5]
[DEBUG] Connection leased: [id: 0][route: {}->http://localhost:8080][total kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 5]
[DEBUG] Connecting to localhost:8080
[DEBUG] CookieSpec selected: best-match
[DEBUG] Re-using cached 'basic' auth scheme for http://localhost:8080
[DEBUG] Target auth state: SUCCESS
[DEBUG] Proxy auth state: UNCHALLENGED
[DEBUG] Attempt 1 to execute request
[DEBUG] Sending request: PUT /manager/text/deploy?path=%2FSpring3HibernateMaven-0.0.1-SNAPSHOT&update=true HTTP/1.1
[DEBUG] >> "PUT /manager/text/deploy?path=%2FSpring3HibernateMaven-0.0.1-SNAPSHOT&update=true HTTP/1.1[\r][\n]"
[DEBUG] >> "User-Agent: Apache Tomcat Maven Plugin/2.1[\r][\n]"
[DEBUG] >> "Content-Length: 11860176[\r][\n]"
[DEBUG] >> "Host: localhost:8080[\r][\n]"
[DEBUG] >> "Connection: Keep-Alive[\r][\n]"
[DEBUG] >> "Authorization: Basic dG9tY2F0OnRvbWNhdA==[\r][\n]"
[DEBUG] >> "[\r][\n]"
[DEBUG] >> PUT /manager/text/deploy?path=%2FSpring3HibernateMaven-0.0.1-SNAPSHOT&update=true HTTP/1.1
[DEBUG] >> User-Agent: Apache Tomcat Maven Plugin/2.1
[DEBUG] >> Content-Length: 11860176
[DEBUG] >> Host: localhost:8080
[DEBUG] >> Connection: Keep-Alive
[DEBUG] >> Authorization: Basic dG9tY2F0OnRvbWNhdA==
Uploading: http://localhost:8080/manager/text/deploy?path=%2FSpring3HibernateMaven-0.0.1-SNAPSHOT&update=true
Uploaded: http://localhost:8080/manager/text/deploy?path=%2FSpring3HibernateMaven-0.0.1-SNAPSHOT&update=true (11583 KB at 1833.5 KB/sec)

[DEBUG] << "HTTP/1.1 401 Unauthorized[\r][\n]"
[DEBUG] << "Server: Apache-Coyote/1.1[\r][\n]"
[DEBUG] << "Cache-Control: private[\r][\n]"
[DEBUG] << "Expires: Wed, 31 Dec 1969 18:00:00 CST[\r][\n]"
[DEBUG] << "WWW-Authenticate: Basic realm="Tomcat Manager Application"[\r][\n]"
[DEBUG] << "Content-Type: text/html;charset=ISO-8859-1[\r][\n]"
[DEBUG] << "Transfer-Encoding: chunked[\r][\n]"
[DEBUG] << "Date: Fri, 20 Sep 2013 05:24:35 GMT[\r][\n]"
[DEBUG] << "[\r][\n]"
[DEBUG] Receiving response: HTTP/1.1 401 Unauthorized
[DEBUG] << HTTP/1.1 401 Unauthorized
[DEBUG] << Server: Apache-Coyote/1.1
[DEBUG] << Cache-Control: private
[DEBUG] << Expires: Wed, 31 Dec 1969 18:00:00 CST
[DEBUG] << WWW-Authenticate: Basic realm="Tomcat Manager Application"
[DEBUG] << Content-Type: text/html;charset=ISO-8859-1
[DEBUG] << Transfer-Encoding: chunked
[DEBUG] << Date: Fri, 20 Sep 2013 05:24:35 GMT
[DEBUG] Connection can be kept alive indefinitely
[DEBUG] localhost:8080 requested authentication
[DEBUG] Authorization challenge processed
[DEBUG] Authentication failed
[DEBUG] Removing from cache 'basic' auth scheme for http://localhost:8080
[DEBUG] << "9ea[\r][\n]"
[DEBUG] << "[\r][\n]"
[DEBUG] << "<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">[\r][\n]"
[DEBUG] << "<html>[\r][\n]"
[DEBUG] << " <head>[\r][\n]"
[DEBUG] << "  <title>401 Unauthorized</title>[\r][\n]"
[DEBUG] << "  <style type="text/css">[\r][\n]"
[DEBUG] << "    <!--[\r][\n]"
[DEBUG] << "    BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;font-size:12px;}[\r][\n]"
[DEBUG] << "    H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}[\r][\n]"
[DEBUG] << "    PRE, TT {border: 1px dotted #525D76}[\r][\n]"
[DEBUG] << "    A {color : black;}A.name {color : black;}[\r][\n]"
[DEBUG] << "    -->[\r][\n]"
[DEBUG] << "  </style>[\r][\n]"
[DEBUG] << " </head>[\r][\n]"
[DEBUG] << " <body>[\r][\n]"
[DEBUG] << "   <h1>401 Unauthorized</h1>[\r][\n]"
[DEBUG] << "   <p>[\r][\n]"
[DEBUG] << "    You are not authorized to view this page. If you have not changed[\r][\n]"
[DEBUG] << "    any configuration files, please examine the file[\r][\n]"
[DEBUG] << "    <tt>conf/tomcat-users.xml</tt> in your installation. That[\r][\n]"
[DEBUG] << "    file must contain the credentials to let you use this webapp.[\r][\n]"

我在 Eclipse 中的运行配置:

Maven Runtime: 3.1.0 ( External )
Goal: -X -e tomcat7:deploy
4

0 回答 0