I know there are many threads talking about it, but I expose a situation that I have not been able to solve with their help. I hope that my problem and if in the future it is solved I can help more people in my situation.
I'm trying to do a hot deployment of a war in Tomcat and I find myself with the following four situations:
Case 1
Deployment command executed from project folder:
mvn clean install org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy -P PROFILE_ONE,PROFILE_TWO -Dmaven.skip.test=true -DskipTests=true -Dmaven.javadoc.skip=true -Dsource.skip=true -Dproject.build.sourceEncoding=UTF-8 -Dcobertura.skip=true -Dmaven.skip.test=true -DskipTests=true -Dmaven.javadoc.skip=true -Dsource.skip=true -Dproject.reporting.outputEncoding=UTF-8 -Dmaven.tomcat.path=/MY_PATH -Dmaven.tomcat.url=http://localhost:8081/manager/text -Dmaven.tomcat.server=TomcatServer -Dtomcat.password=TOMCAT_USER -Dtomcat.username=TOMCAT_PASSWORD
AND apache-tomcat-7.0.91\conf\context.xml with the following properties:
<Context antiResourceLocking="true" antiJARLocking="true">
Case 1 result
The deployment seems to work fine but when I enter the application the following error appears:
This page can not be found (localhost) No web page was found for the address http://localhost:8081/MY_PATH/#/PATH. HTTP ERROR 404
Case 2
Same command of case 1 executed from project folder and apache-tomcat-7.0.91\conf\context.xml without antilocking properties:
<Context>
Case 2 result
The deployment and the application work correctly, but when I try to do a redeploy, with the same command and adding the property -Dmaven.tomcat.update=true
does not work correctly because there are several jars that are blocked and tomcat cannot delete them. (This is the reason why in other cases I add antilocking properties)
Case 3
Same command of case 1 executed from project folder and apache-tomcat-7.0.91\conf\context.xml with the following properties:
<Context antiJARLocking="true">
Case 3 result
Equal to the result of case 2.
Case 4
Same command of case 1 executed from project folder and apache-tomcat-7.0.91\conf\context.xml with the following properties:
<Context antiResourceLocking="true">
Case 4 result
Equal to the result of case 1.
end of cases
As you can see, my goal is to do a first deployment and then redeploy the same application (with changes in project folder). All the information I have found talks about the antilocking properties, but as I said above, when I put them on context.xml, the application it seems not to work. It is important to say that due to project needs I cannot change the name of the war.
EDIT 1
Case 5
I have also tried with the following command:
mvn clean install -U -P PROFILE_ONE,PROFILE_TWO -Dmaven.skip.test=true -DskipTests=true -Dmaven.javadoc.skip=true -Dsource.skip=true -Dproject.build.sourceEncoding=UTF-8 -Dcobertura.skip=true -Dmaven.skip.test=true -DskipTests=true -Dmaven.javadoc.skip=true -Dsource.skip=true -Dproject.reporting.outputEncoding=UTF-8 org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:redeploy-only -Dmaven.tomcat.path=/MY_PATH -Dmaven.tomcat.url=http://localhost:8081/manager/text -Dmaven.tomcat.server=TomcatServer -Dtomcat.password=admin -Dtomcat.username=admin
And apache-tomcat-7.0.91\conf\context.xml with the following properties:
<Context antiResourceLocking="true">
Case 5 Result KO
Equal to the result of case 1.
Why antiResourceLocking="true"
causes result 1 error?
You shouldn't use both
antiResourceLocking
andantiJARLocking
features according to Tomcat:There also specific warnings about using antiResourceLocking