How to redeploy a war on remote Tomcat 7 using maven-tomcat-plugin
Asked Answered
S

5

5

I am trying to redeploy a war from my local machine to a remote Tomcat 7 using command prompt in Windows. I am able to upload the war with the tomcat-maven-plugin for the first time but subsequent uploads gives me a message something like this.

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

mvn tomcat7:redeploy

Maven Log:

[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] ------------------------------------------------------------------------
Slowmoving answered 26/3, 2014 at 19:40 Comment(0)
C
6

I also had this problem. For me it worked putting in the update-tag in the tomcat-plugin

        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>     
            ... 
            <update>true</update>

            ...

and using the tomcat7:deploy command (and not 'redeploy') again.

(just noticed the answer still was there..., sorry for duplicating)

Christcross answered 13/4, 2014 at 9:35 Comment(0)
C
4

This happens probably due to the file being locked by tomcat.

you can unlock it by adding <Context antiResourceLocking="true"> to tomcat context

Crompton answered 26/3, 2014 at 19:52 Comment(6)
I tried adding <Context antiJARLocking="true" antiResourceLocking="true" path="/istore-tax-service"/> but it did not work. Still getting the same exception.Slowmoving
I changed my target deployment from Unix-based Tomcat to Windows-based Tomcat and it worked without any problems. Is there any additional configuration required for deploying to Unix-based Tomcats?Slowmoving
Your problem could be with file permissions on the unix server.. does your tomcat user on unix have permissions to delete the files?Crompton
"antiJARLocking is a subset of antiResourceLocking and therefore, to prevent duplicate work and possible issues, only one of these attributes should be set to true at any one time."Crompton
Ok. My IDE automcatically adds the antiJARLocking="true" property when context.xml is created. However, I see that this error is occurring intermittently on Windows machine also. Not sure what's going on.Slowmoving
Talking about locking, I had a similar problem using the Tomcat (web) manager with undeletable files due to locking; it turned out that there was an unclosed InputStream on that file. After fixing that I did't experience such locking anymore and each undeploy goes fine. It may be worth a check :-)Prostitution
B
2

Use

<update>true</update>

http://tomcat.apache.org/maven-plugin-2.2/tomcat7-maven-plugin/deploy-mojo.html#update

Benne answered 27/3, 2014 at 4:25 Comment(1)
If you look at the logs I mentioned above update=true gets added automatically at the end of the url. Is this what you are talking about ?Slowmoving
L
1

This problem happened to me when deploying maven application from Netbeans IDE 8.0.2 and path in context.xml was set with trailing slash.

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

Removing the trailing slash resolved the issue for me.

<Context antiJARLocking="true" path="/foo" />
Likable answered 19/12, 2014 at 8:53 Comment(0)
O
0

I added antiJARLocking = "true" to my context.xml file as follows

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

then right click on project and select "Clean and Build",

and RUN your project.

This worked for me.

Oxygen answered 30/1, 2017 at 2:25 Comment(1)
This is not an answer to the question, it's a comment/new question. Once you have sufficient reputation (50) you will be able to comment on any post. In the meantime you can gain reputation by asking your own questions or providing answers on subjects you know.Payola

© 2022 - 2024 — McMap. All rights reserved.