2014-04-20 116 views
3

我想部署我的項目使用Eclipse IDE來tomcat7,我面臨着這樣的錯誤:錯誤403當嘗試部署與Tomcat的Maven的插件Maven項目

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 

我的pom.xml有這個配置:

<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> 

我的tomcat-users.xml中是:

<?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> 

任何人都可以指向我什麼,我做錯了什麼?

回答

5

該文檔提到應將遠程部署命令發送到url manager/text,請參閱Deploy A New Application Remotely

通過更改配置到該網址,而不是,它應該工作:

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

而且Tomcat有一些預先定義的角色做某些任務,嘗試添加角色manager-script

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

好的,我做到了。我目前的問題是,當我啓動tomcat(通過eclipse)時,tomcat-users.xml文件被重新定義,並且我在文件中插入的數據將丟失。當我啓動tomcat後重新打開這個文件時,文件的內容與我保存的完全不同。 –

+1

檢查資源管理器樹中的「服務器」部分,這些是在每個部署上覆蓋服務器的tomcat文件。嘗試直接編輯這些。 –

2

我在eclipse配置面板中更改了tomcat的服務器位置配置。 以這種方式,eclipse直接使用您的tomcat安裝配置而不是工作區元數據。根據這個問題和類似的問題和答案進行所有步驟後,這一步終於爲我解決了這個問題。 問題前提條件:Eclipse Luna,Maven 3.1,動態Web項目,maven-war-plugin,tomcat 7

下圖顯示了適合我的配置,解決了OP的相同問題。

Eclipse Tomcat Server Config Panel (reachable by double-click on the server name within the server view