简体   繁体   中英

Maven fail to deploy web application at Tomcat server in Mac OS X

I am trying deploy a web application at Tomcat server in a Mac OS X system using Maven. I already accomplish do this in a Linux and Windows System. But in the Mac OS XI am facing this error:

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

I have edited my file tomcat-users.xml inside the folder workspace/Server/Tomcat v7.0 Server at localhost-config to include this:

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

and in my pon.xml I add this too:

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

Anyone can give some hint to make this work? I can't figure out a reason why this works in Linux/Windows and don`t work in MacOSX.

I had the same problem. I changed 2.2 to 2.0 and worked for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM