您好我正在尝试使用maven部署我的应用程序。通过Web界面部署woks。但是maven首先取消使用app(这是rght)然后在logmessage“Uploaded”停止大约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]
是否可以更改部署的超时?也许我的应用需要很长时间才能开始
编辑: 我发现当我签出项目并运行tomcat7:在运行tomcat的同一台机器上运行时,它可以工作
答案 0 :(得分:3)
虽然答案很晚,但有人可能觉得这很有用。 如果你使用的是maven3和tomcat7.下面的方法对我有用。我不知道tomcat7中应用程序管理器端点的变化。
Environment - Apache Maven 3.0.4,apache-tomcat-7.0.34,Windows 7
Tomcat7已将其部署终点从http://tomcatserver:8080/manager/html
更改为http://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
答案 1 :(得分:1)
我猜你现在正在执行目标tomcat:deploy,而不是尝试运行目标 tomcat:redeploy ,并确保你已经在pom中添加了tomcat-maven-plugin。 XML