【问题标题】:Maven fail to deploy web application at Tomcat server in Mac OS XMaven 无法在 Mac OS X 的 Tomcat 服务器上部署 Web 应用程序
【发布时间】:2014-06-08 12:26:32
【问题描述】:

我正在尝试使用 Maven 在 Mac OS X 系统中的 Tomcat 服务器上部署 Web 应用程序。我已经在 Linux 和 Windows 系统中完成了这项工作。但是在 Mac OS X 中我遇到了这个错误:

Uploading: http://localhost:8080/manager/text/deploy?path=%2Floja
Uploaded: http://localhost:8080/manager/text/deploy?path=%2Floja (14335 KB at 73508.0 KB/sec)

[ERROR] Tomcat return http status error: 403, Reason Phrase: Forbidden
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.646s
[INFO] Finished at: Sun Jun 08 09:19:55 GMT-03:00 2014
[INFO] Final Memory: 10M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy (default-cli) on project cms: Tomcat return http status error: 403, Reason Phrase: Forbidden:
[ERROR] <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
[ERROR] <html>
[ERROR] <head>
[ERROR] <title>403 Access Denied</title>
[ERROR] <style type="text/css">
[ERROR] <!--
[ERROR] BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;font-size:12px;}
[ERROR] H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
[ERROR] PRE, TT {border: 1px dotted #525D76}
[ERROR] A {color : black;}A.name {color : black;}
[ERROR] -->
[ERROR] </style>
[ERROR] </head>
[ERROR] <body>
[ERROR] <h1>403 Access Denied</h1>
[ERROR] <p>
[ERROR] You are not authorized to view this page.
[ERROR] </p>
[ERROR] <p>
[ERROR] If you have already configured the Manager application to allow access and
[ERROR] you have used your browsers back button, used a saved book-mark or similar
[ERROR] then you may have triggered the cross-site request forgery (CSRF) protection
[ERROR] that has been enabled for the HTML interface of the Manager application. You
[ERROR] will need to reset this protection by returning to the
[ERROR] <a href="/manager/html">main Manager page</a>. Once you
[ERROR] return to this page, you will be able to continue using the Manager
[ERROR] appliction's HTML interface normally. If you continue to see this access
[ERROR] denied message, check that you have the necessary permissions to access this
[ERROR] application.
[ERROR] </p>
[ERROR] <p>
[ERROR] If you have not changed
[ERROR] any configuration files, please examine the file
[ERROR] <tt>conf/tomcat-users.xml</tt> in your installation. That
[ERROR] file must contain the credentials to let you use this webapp.
[ERROR] </p>
[ERROR] <p>
[ERROR] For example, to add the <tt>manager-gui</tt> role to a user named
[ERROR] <tt>tomcat</tt> with a password of <tt>s3cret</tt>, add the following to the
[ERROR] config file listed above.
[ERROR] </p>
[ERROR] <pre>
[ERROR] &lt;role rolename="manager-gui"/&gt;
[ERROR] &lt;user username="tomcat" password="s3cret" roles="manager-gui"/&gt;
[ERROR] </pre>
[ERROR] <p>
[ERROR] Note that for Tomcat 7 onwards, the roles required to use the manager
[ERROR] application were changed from the single <tt>manager</tt> role to the
[ERROR] following four roles. You will need to assign the role(s) required for
[ERROR] the functionality you wish to access.
[ERROR] </p>
[ERROR] <ul>
[ERROR] <li><tt>manager-gui</tt> - allows access to the HTML GUI and the status
[ERROR] pages</li>
[ERROR] <li><tt>manager-script</tt> - allows access to the text interface and the
[ERROR] status pages</li>
[ERROR] <li><tt>manager-jmx</tt> - allows access to the JMX proxy and the status
[ERROR] pages</li>
[ERROR] <li><tt>manager-status</tt> - allows access to the status pages only</li>
[ERROR] </ul>
[ERROR] <p>
[ERROR] The HTML interface is protected against CSRF but the text and JMX interfaces
[ERROR] are not. To maintain the CSRF protection:
[ERROR] </p>
[ERROR] <ul>
[ERROR] <li>Users with the <tt>manager-gui</tt> role should not be granted either
[ERROR] the <tt>manager-script</tt> or <tt>manager-jmx</tt> roles.</li>
[ERROR] <li>If the text or jmx interfaces are accessed through a browser (e.g. for
[ERROR] testing since these interfaces are intended for tools not humans) then
[ERROR] the browser must be closed afterwards to terminate the session.</li>
[ERROR] </ul>
[ERROR] <p>
[ERROR] For more information - please see the
[ERROR] <a href="/docs/manager-howto.html">Manager App HOW-TO</a>.
[ERROR] </p>
[ERROR] </body>
[ERROR] 
[ERROR] </html>
[ERROR] -> [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

我已经在文件夹workspace/Server/Tomcat v7.0 Server at localhost-config 中编辑了我的文件 tomcat-users.xml 以包含以下内容:

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

在我的 pon.xml 中我也添加了这个:

<build>
    <finalName>lojavirtual</finalName>
    <plugins>
                <plugin>
                      <groupId>org.apache.tomcat.maven</groupId>
                      <artifactId>tomcat7-maven-plugin</artifactId>
                      <version>2.2</version>
                      <configuration>
                          <url>http://localhost:8080/manager/text</url>
                          <server>TomcatServer</server>
                          <path>/loja</path>
                          <username>user001</username>
                          <password>123</password>
                      </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <configuration>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>
                </plugin>
    </plugins>
</build>

任何人都可以给出一些提示来完成这项工作吗?我不知道为什么这在 Linux/Windows 中有效而在 MacOSX 中无效。

【问题讨论】:

标签: java macos maven tomcat


【解决方案1】:

我遇到了同样的问题。我将 2.2 更改为 2.0 并为我工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-23
    • 2015-05-16
    • 1970-01-01
    • 2012-10-01
    • 1970-01-01
    • 2020-07-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多