如何使用maven-tomcat-plugin在远程Tomcat 7上重新部署战争

时间:2014-03-26 19:40:37

标签: maven tomcat7 maven-tomcat-plugin

我正在尝试使用Windows中的命令提示符将战争从本地计算机重新部署到远程Tomcat 7。我能够第一次使用tomcat-maven-plugin上传战争,但后续的上传给了我这样的消息。

的pom.xml

 <!-- Deploy to Remote Tomcat -->
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <url>${unix.tomcat.url}</url>
                    <server>sandbox-tomcat</server>
                    <path>/${project.artifactId}</path>
                </configuration>
            </plugin>

Maven命令:

mvn tomcat7:redeploy

Maven日志:

[INFO] Deploying war to http://secdevapp11.gspt.net:8080/istore-tax-service
Uploading: http://secdevapp11.gspt.net:8080/manager/text/deploy?path=%2Fistore-tax-service&update=true
Uploaded: http://secdevapp11.gspt.net:8080/manager/text/deploy?path=%2Fistore-tax-service&update=true (1334 KB at 512.7 KB/sec)

[INFO] tomcatManager status code:200, ReasonPhrase:OK
[INFO] FAIL - Unable to delete [/nfs/home_04/chandeln/installations/apache-tomcat-7.0.52/webapps/istore-tax-service]. The continued presence of this file may cause problems.
[INFO] FAIL - Application already exists at path /istore-tax-service
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.704s
[INFO] Finished at: Wed Mar 26 15:34:55 EDT 2014
[INFO] Final Memory: 21M/224M
[INFO] ------------------------------------------------------------------------

5 个答案:

答案 0 :(得分:5)

我也有这个问题。 对我来说,它在tomcat-plugin

中加入了update-tag
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>     
            ... 
            <update>true</update>

            ...

并再次使用tomcat7:deploy命令(而不是'redeploy')。

(刚刚注意到答案仍然存在......,抱歉复制)

答案 1 :(得分:3)

这可能是由于文件被tomcat锁定所致。

您可以通过将<Context antiResourceLocking="true">添加到tomcat上下文

来解锁它

答案 2 :(得分:2)

答案 3 :(得分:1)

当从Netbeans IDE 8.0.2部署maven应用程序时,我遇到了这个问题,而context.xml中的路径设置了尾部斜杠。

<Context antiJARLocking="true" path="/foo/" />

删除尾部斜杠解决了我的问题。

<Context antiJARLocking="true" path="/foo" />

答案 4 :(得分:0)

我将antiJARLocking =“true”添加到我的context.xml文件中,如下所示

TRUE on success, FALSE on failure

然后右键单击项目并选择“清理并构建”,

并运行您的项目。

这对我有用。