This error is quite puzzling. In my webapps, I have the log4j.properties in WEB-IF/classes as per recommendation.
When I deploy from eclipse, I do a stop on the webapp, undeploy, and then deploy. Strangely enough, 8 out of 10 times I get the following error on undeploy-
build.xml:526: FAIL - Unable to delete [C:\\Program Files\\Apache Software Foundation\\Tomcat 7.0\\webapps\\punch]. The continued presence of this file may cause problems.
The only file remaining under my webapp is the WEB-INF/classes/log4j.properties. Everything else is deleted.
I cannot manually delete the file or the webapp folder either. I have to stop Tomcat service, delete the folder and then restart.
Is there any solution for this?
Thanks.
Here is my remove task in build.xml
<target name="remove"
description="Remove application on servlet container">
<stop url="${manager.url}"
username="${manager.username}"
password="${manager.password}"
path="${app.path}"/>
<undeploy url="${manager.url}"
username="${manager.username}"
password="${manager.password}"
path="${app.path}"/>
</target>
That's because the file is opened for reading. You need to at least shutdown your app. That can easily be done with PsiProbe .
Make sure you call LogManager.shutdown() in the contextDestroyed() method of a ServletContextListener. That should ensure that log4j doesn't have the file open.
Here is my work around:
I created another target to copy the war to Tomcat's webapp directory.
<target name="copywar" depends="dist">
<copy file="${dist.home}/${app.name}.war" todir="${catalina.home}/webapps" />
</target>
I also made sure that Tomcat could redeploy with this in server.xml
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
This works just fine. Thanks for your help folks.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.