Bug 10026 - manager/stop and manager/remove
Summary: manager/stop and manager/remove
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 4
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 4.1.31
Hardware: PC All
: P3 normal with 5 votes (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
: 8763 15484 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-06-19 19:55 UTC by Roger Nell
Modified: 2005-09-23 14:08 UTC (History)
4 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Roger Nell 2002-06-19 19:55:44 UTC
When I stop or remove a struts application there is a lock on struts.jar and 
the applications directory under webapps cannot be removed.  Cross posted under 
struts.

To reproduce:
  Get file 'struts-blank.war' from the struts 1.0 or 1.1Beta binary 
distribution.
  Put above file in webapps directory.
  Start Tomcat
  In browser type: 'http://localhost:8080/manager/stop?path=/struts-blank
     Answer password prompt - see tomcat-users.xml in conf directory
     Verify an 'OK' response.
  Delete 'struts-blank' directory from webapps directory.
  Delete fails because struts.jar is locked.
Comment 1 Glenn Nielsen 2003-01-10 02:32:42 UTC
I can't reproduce this problem with Tomcat 4.1.18. Please let me know if you
are still having problems with this.  If you are, could you please test with
Tomcat 4.1.18 to see if it still exists.
Comment 2 Yann Cébron 2003-01-16 12:54:42 UTC
Tomcat: 4.1.18/4.1.19
JDK: 1.4.1
System: W2K SP3

I can reproduce this bug on 4.1.18 and 4.1.19 (also with other applications 
using struts.jar), but it seems rather related to Struts itself since removal 
of any other webapps works fine for me.
Comment 3 Glenn Nielsen 2003-01-16 13:21:51 UTC
I will mark this bug as invalid for Tomcat then.  Please work with the
struts team to resolve it.  Thanks for checking.
Comment 4 Yann Cébron 2003-01-18 12:19:38 UTC
Sorry, apparently I got to reopen this, please read Craig's comments on #10027:

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10027

Seems this problem is related to Tomcat locking (at least some) JARs on WIN
Comment 5 Mark Volkmann 2003-04-11 19:30:00 UTC
This also occurs with axis.jar.  Very frustrating!
Comment 6 Tony Chao 2003-06-13 18:14:42 UTC
A similar bug was fixed in Log4J. While it's arguable whether it's a struts 
bug, tomcat bug, or a windows bug, I thought I'd post the details to see if 
anyone has ideas on how tomcat can fix this.

The bug (from what I understand) is that when dtd's are loaded from the jar 
(while running on windows), the jar is locked b/c the input stream for the dtd 
has not be properly closed. In log4j, this is fixed by using a custom 
EntityResolver to load the dtd. (the resolver makes a copy of the dtd input 
stream in memory and return the copied stream after closing the real input 
stream)

references to this can be found in the log4j code, but this url from the 
barracuda project has a pretty good summary:
http://barracuda.enhydra.org/software/cvs/cvsweb.cgi/Projects/EnhydraOrg/toolsT
ech/Barracuda/WEB-INF/lib/log4j-1.2.7a.jar?rev=1.1&content-type=text/x-cvsweb-
markup

the files of interest in log4j are:
org/apache/log4j/xml/Log4jEntityResolver.java
org/apache/log4j/xml/DOMConfigurator.java

is there some way for tomcat to always use a custom EntityResolver if the 
system is windows?

Something that may also be of interest:
I've found that if I expand the jar and dump all the files into WEB-
INF/classes, there are problems undeploy/removing the app
Comment 7 Tony Chao 2003-06-13 18:15:37 UTC
sorry, typo.

that should read:

I've found that if I expand the jar and dump all the files into 
WEB-INF/classes, there are NO problems undeploy/removing the app
Comment 8 Remy Maucherat 2003-06-13 18:35:56 UTC
I have specifically investigated this problem during the past few days, and can
draw the same conclusions. There's unfortunately little or nothing that Tomcat
can do.

Here's what happens:
- XML paser uses get resource to load the DTD
- Tomcat returns a jar:file: URL, as the DTD is inside a JAR
- XML parser does read from that without setting setUseCaches(false), so this
causes the JAR to be locked until the VM is terminated

Tomcat cannot do anything about it, unless we add custom code in getResource to
handle non class resources (ex: we could extract the resource to teh work dir,
and return a file URL to there). AFAIK, there's nothing which forbids that, so
I'll experiment with doing that in TC 5.
Comment 9 Tony Chao 2003-06-17 22:31:40 UTC
*** Bug 8763 has been marked as a duplicate of this bug. ***
Comment 10 Yann Cébron 2003-07-15 19:30:14 UTC
WORKSFORME for struts.jar in TC5.0.4 on WinXP (both stop and undeploy)
Comment 11 Mark Thomas 2005-04-14 23:13:13 UTC
*** Bug 15484 has been marked as a duplicate of this bug. ***
Comment 12 Mark Thomas 2005-09-23 22:08:40 UTC
I have ported the antiJARLocking functionality from TC5 and successfully tested
it with antiJARLocking="true" using a struts app (a copy of the Tomcat Admin app).

The fix will be included in 4.1.32 onwards. Note there is no date currently
planned for a 4.1.32 release.