Bug 34076 - overriding content.xml docBase with manager webapp deploy function fails with java.util.zip.ZipException if context.xml specifies war and manager specifies directory
Summary: overriding content.xml docBase with manager webapp deploy function fails with...
Status: RESOLVED WONTFIX
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Webapps:Manager (show other bugs)
Version: 5.0.28
Hardware: PC Windows 2000
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL: http://localhost:8080/manager
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-18 18:10 UTC by Daniel Santos
Modified: 2006-09-10 18:41 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Santos 2005-03-18 18:10:07 UTC
When using the manager webapp specifying to deploy a local directory with the
war parameter and specifying a context.xml that specifies a war file with the
docBase parameter, the manager fails with java.util.zip.ZipException.

Here is an example deployment URL
http://localhost:8080/manager/deploy?config=file://C:/Projects/tts/apps/tts-webapp/src/conf/tts-dev-local.xml&war=file://C:/Projects/tts/apps/tts-webapp/build/war

Error Message:
FAIL - Encountered exception java.io.IOException: java.util.zip.ZipException:
The system cannot find the file specified

where:
    the URL file://C:/Projects/tts/apps/tts-webapp/src/conf/tts-dev-local.xml
    points to a file containing this config (slightly abreviated):
    <Context displayName="My App Name" path="" docBase="tts.war" debug="99">
        ... some stuff ...
    </Context>

    the URL file://C:/Projects/tts/apps/tts-webapp/build/war points to my
    directory where I construct a war-format layout with my webapp

If I change the docBase in the context.xml to "tts.wart" it deploys:
OK - Deployed application from context file
file://C:/Projects/tts/apps/tts-webapp/src/conf/tts-dev-local.xml

It appears that the determination of whether we are deploying from a war file or
a directory is made when the context.xml is read and isn't overriden when the
"war" parameter to the manager's "deploy" action is specified.  Therefore, it's
either still using the value from the context.xml (and looking for it under
webapps) or it's trying to open the directory as a zip file or the directory
plus + ".war" or something.
Comment 1 Daniel Santos 2005-04-11 18:27:18 UTC
More info on this bug:

The context.xml that you supply to the Manager is unaltered, it appears to be
copied verbatim to $CATALINA_HOME/conf/<serviceName>/<hostName>/ (where
context.xml files go).  The next time that Tomcat starts, it reads these values
and will thus deploy (or attempt to deploy) differently than when it was
deployed with the Manager specifying the overriding parameters.

I think that the solution is to re-write the context.xml file rather than adding
code to handle the special case of the overridden war file.  After it is
re-written, it can then be parsed and processed as though there were no
exceptions.  This would solve several problems at once.  If I understand the
commons component correctly that creates these objects (which I only barely
understand it) from the xml then we would only be running that after we re-wrote
the xml.

That would solve both problems, the ".war file vs. war layout directory" issue
and the "next time you boot Tomcat it uses old war value" issue.  Then the file
could be written to conf/<service name>/<host name> correctly and it's much
smoother.

Now, how should we re-write it?  We can parse it, change the values and then
write it out or we can basically find and replace hack it.  But I'm personally
for a more sophisticated solution that is probably a bigger mouthful then
anybody wants, but it's an idea....

I have long since been unsatisfied with the Admin webapps behavior of writing
out my xml files with comments stripped and it's own (not too friendly)
formatting.  It would be really nice if there was a somewhat extended parsing
functionality that records comments as metadata.  If we wanted to go a bit
further, we could also attempt to analyze the formatting to determine what
formatting conventions is being used along with a probability factor of how
certain they are using that convention (some people just sorta throw up in their
code editor and call it art).  Then, when we write it, we can write the comments
back out and reusing their original formatting convention if it was consistent
enough, or use a better formatting convention than we are currently at least.

Daniel
Comment 2 Yoav Shapira 2005-07-23 00:15:17 UTC
Daniel, does this happen in 5.5.9?  Chances of it getting fixed in 5.0 are slim...
Comment 3 Mark Thomas 2006-09-11 01:41:49 UTC
This is handled cleanly (with a single warning on Tomcat restart) by the latest
5.5.x code.

Given that there has been little development on the 5.0.x branch for some time
and little chance of future development I am closing this as WONTFIX for 5.0.x