Tomcat7 maven插件部署failonerror

时间:2013-06-25 04:38:35

标签: java maven tomcat deployment tomcat7

我正在使用apache tomcat maven插件将war文件部署到远程tomcat服务器。这是我在pom.xml中的插件配置,

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.1</version>
    <configuration>
        <url>http://localhost:8080/manager/text</url>
        <server>INT</server>
    </configuration>
</plugin>

当我运行maven构建并且由于某种原因部署失败时,maven构建仍然显示BUILD SUCCESS

[INFO] tomcatManager status code:401, ReasonPhrase:Unauthorized
[INFO] <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/h
tml4/strict.dtd">
[INFO] <html>
[INFO]  <head>
[INFO]   <title>401 Unauthorized</title>
[INFO]   <style type="text/css">
[INFO]     <!--
[INFO]     BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-colo
r:white;font-size:12px;}
[INFO]     H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:
#525D76;font-size:22px;}
[INFO]     PRE, TT {border: 1px dotted #525D76}
[INFO]     A {color : black;}A.name {color : black;}
[INFO]     -->
[INFO]   </style>
[INFO]  </head>
[INFO]  <body>
[INFO]    <h1>401 Unauthorized</h1>
[INFO]    <p>
[INFO]     You are not authorized to view this page. If you have not changed
[INFO]     any configuration files, please examine the file
[INFO]     <tt>conf/tomcat-users.xml</tt> in your installation. That
[INFO]     file must contain the credentials to let you use this webapp.
[INFO]    </p>
[INFO]    <p>
[INFO]     For example, to add the <tt>manager-gui</tt> role to a user named
[INFO]     <tt>tomcat</tt> with a password of <tt>s3cret</tt>, add the following
 to the
[INFO]     config file listed above.
[INFO]    </p>
[INFO] <pre>
[INFO] &lt;role rolename="manager-gui"/&gt;
[INFO] &lt;user username="tomcat" password="s3cret" roles="manager-gui"/&gt;
[INFO] </pre>
[INFO]    <p>
[INFO]     Note that for Tomcat 7 onwards, the roles required to use the manager

[INFO]     application were changed from the single <tt>manager</tt> role to the

[INFO]     following four roles. You will need to assign the role(s) required fo
r
[INFO]     the functionality you wish to access.
[INFO]    </p>
[INFO]     <ul>
[INFO]       <li><tt>manager-gui</tt> - allows access to the HTML GUI and the st
atus
[INFO]           pages</li>
[INFO]       <li><tt>manager-script</tt> - allows access to the text interface a
nd the
[INFO]           status pages</li>
[INFO]       <li><tt>manager-jmx</tt> - allows access to the JMX proxy and the s
tatus
[INFO]           pages</li>
[INFO]       <li><tt>manager-status</tt> - allows access to the status pages onl
y</li>
[INFO]     </ul>
[INFO]    <p>
[INFO]     The HTML interface is protected against CSRF but the text and JMX int
erfaces
[INFO]     are not. To maintain the CSRF protection:
[INFO]    </p>
[INFO]    <ul>
[INFO]     <li>Users with the <tt>manager-gui</tt> role should not be granted ei
ther
[INFO]         the <tt>manager-script</tt> or <tt>manager-jmx</tt> roles.</li>
[INFO]     <li>If the text or jmx interfaces are accessed through a browser (e.g
. for
[INFO]         testing since these interfaces are intended for tools not humans)
 then
[INFO]         the browser must be closed afterwards to terminate the session.</
li>
[INFO]    </ul>
[INFO]    <p>
[INFO]     For more information - please see the
[INFO]     <a href="/docs/manager-howto.html">Manager App HOW-TO</a>.
[INFO]    </p>
[INFO]  </body>
[INFO] </html>
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.216s
[INFO] Finished at: Tue Jun 25 09:59:51 PST 2013
[INFO] Final Memory: 9M/23M
[INFO] ------------------------------------------------------------------------
D:\Workspace\SVN\webroot>

我注意到以前的org.codehaus.mojo插件不是这种情况。有没有办法设置FailOnError以便我知道部署何时失败?

2 个答案:

答案 0 :(得分:0)

我的版本中的相同问题。它看起来像我的bug。

这个插件在我的情况下适用于Tomcat7,没有任何配置更改:

<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>

答案 1 :(得分:0)

在2.2版中,此错误已得到修复。

<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>