Shahe
Shahe

Reputation: 984

Undeploy web application from tomcat doesn't remove the deployed directory

I am using tomcat manager commands to deploy and undeploy web applications on a tomcat server. The problem is when I try to undeploy a web application, it does remove the .war file from the webapps directory but the exploded directory doesn't get removed (the WEB-INF/lib folder), neither from the List Applications in the tomcat mananger.

I am on Windows and I am using Tomcat 6.0.20.

Note: When I tried to delete the directory manually it gave me an error saying that the file is being used by another program.

Upvotes: 7

Views: 22461

Answers (4)

eric Osman
eric Osman

Reputation: 1

In my case, I found the culprit and also found how to reproduce the issue.

The culprit was that my servlet opened files by using the Scanner class and neglected to use Scanner.close after reading the files. The files being opened were ones in WEB-INF/classes and hence tomcat's undeploy operation couldn't delete the contents of the WEB-INF/classes folder.

Here's the scenario to reproduce the issue (before fixing it by adding calls to Scanner.close):

  1. Stop and restart tomcat
  2. Copy my war file to webapps to force redeployment.
  3. Run my servlet twice by invoking its url from the browser.
  4. Copy war file to webapps again to force another redeployment. This is when the issue occurred.

After adding Scanner.close invocation, the above scenario no longer has any issues.

Upvotes: 0

Tung
Tung

Reputation: 5444

I was on Windows using cygwin. Even after shutting down tomcat, I could not delete the web application folder - the command kept on returning "Device or resource busy". I noticed that the java process was still running even after I had shut down tomcat so I decided to kill it, and was able to manually delete the web application folder.

Upvotes: 0

Shahe
Shahe

Reputation: 984

I found the solution, just put this in your context.xml file in your_tomcat_home_directory/Config:

<Context antiJARLocking="true" antiResourceLocking="true">

Everything works fine.

Upvotes: 15

JeroenVP
JeroenVP

Reputation: 175

Try to stop your Tomcatserver(-service), then you can manually delete the exploded directory, then restart it agian.

Upvotes: 0

Related Questions