3

您好我正在尝试使用 Maven 部署我的应用程序。通过 web 界面部署炒锅。但是 maven 首先取消部署应用程序(这是正确的),然后在日志消息“已上传”处停止 ca.30 秒并失败:

tomcat7:部署

[INFO] Deploying war to http://192.168.1.137:8080/Application
Uploading: http://192.168.1.137:8080/manager/html/deploy?path=%2FApplication&update=true
Uploaded: http://192.168.1.137:8080/manager/html/deploy?path=%2FApplication&update=true (17575 KB at 23215.6 KB/sec)

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 57.061s
[INFO] Finished at: Mon Aug 06 09:41:27 CEST 2012
[INFO] Final Memory: 19M/220M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.0-beta-1:deploy (default-cli) on project Application: Cannot invoke Tomcat manager: The target server failed to respond -> [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 中的配置

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <configuration>
        <url>http://192.168.1.137:8080/manager/html</url>
        <username>admin</username>
        <password>password</password>
        <path>/Application</path>
        <update>true</update>
    </configuration>
</plugin>

我还尝试了使用 tomcat:redeploy 的旧插件:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>tomcat-maven-plugin</artifactId>
    <configuration>
        <url>http://192.168.1.137:8080/manager/html</url>
        <username>admin</username>
        <password>password</password>
        <path>/Application</path>
    </configuration>
</plugin>

但它也失败了:

[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:redeploy (default-cli) on project Application: Cannot invoke Tomcat manager: Unexpected end of file from server -> [Help 1]

是否可以更改部署的超时时间?也许我的应用程序需要很长时间才能启动

编辑:我发现当我签出项目并在运行 tomcat 的同一台机器上运行 tomcat7:deploy 时,它可以工作

4

2 回答 2

3

虽然答案较晚,但有人可能会觉得这很有用。如果您使用的是 maven3 和 tomcat7。下面的方法对我有用。我不知道 tomcat7 中应用程序管理器端点的变化。

Environment - Apache Maven 3.0.4,apache-tomcat-7.0.34,Windows 7

Tomcat7 已将其部署端点从 更改http://tomcatserver:8080/manager/htmlhttp://tomcatserver:8080/manager/text .

所以我的 pom.xml 将是

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>tomcat-maven-plugin</artifactId>
     <configuration>
           <url>http://tomcatserver:8080/manager/text</url>
           <server>tomcat</server>
          <path>/myWebApp</path>
         </configuration>
  </plugin>

在 tomcat-users.xml 中

<role rolename="manager-gui"/>
  <role rolename="manager-script"/>
  <role rolename="manager-jmx"/>
  <role rolename="manager-status"/>
  <role rolename="admin-gui"/>
  <role rolename="admin-script"/>

  <user username="root" password="root" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/>

在 Maven settings.xml 中

<server>
  <id>tomcat</id>
  <username>root</username>
  <password>root</password>
</server>

在 context.xml 中,虽然这是可选的,并且与 maven3 部署到 tomcat7 无关,但有时可能会发生 jar 锁定,所以为了更安全。

<Context  antiJARLocking="true" antiResourceLocking="true">

现在发行

mvn tomcat:deploy

记得在部署maven之前启动tomcat。

如果部署成功,您的应用程序将在

http://tomcatserver:8080/myWebApp
于 2013-04-07T04:03:27.547 回答
1

我猜你现在正在执行目标 tomcat:deploy,而不是那样,尝试运行目标tomcat:redeploy并确保你在 pom.xml 中添加了 tomcat-maven-plugin

于 2012-08-06T08:12:48.770 回答