If you upload a war file using the HTML manager interface it places the war file in the webapps directory. It also extracts the context.xml file and places this in conf/Catalina/localhost using the war file to generate the new filename. So if the war file is called MyApp.war, the context file is MyApp.xml. So far, so good. If the context file declares the path to be "/myapp" the application is deployed in the context /myapp. Now, if you restart the server you get two instances of your application. One because of the MyApp.war file in webapps - this is deployed as /MyApp. The second is due to the context file (MyApp.xml) but this deploys as /myapp. I don't know what the correct behaviour should be but the restriction is that your path must be the same as the war filename.
Turn off autoDeploy and this won't happen. It's not a Tomcat bug, merely a configuration issue.
I did have the flag autoDeploy set to false but your comment pointed me in the right direction. The flag that needs turning off is in fact deployOnStartup. So the host element needs to be: <Host name="localhost" debug="0" appBase="webapps" unpackWARs="false" autoDeploy="false" deployOnStartup="false"> I think there is still an issue around the documentation. The help on Automatic Application Deployment is misleading (http://jakarta.apache.org/tomcat/tomcat- 5.0-doc/config/host.html#Automatic%20Application%20Deployment). 1. I think the first action happens even when deployOnStartup is false - I didn't try this attribute because I thought it would stop things deploying on startup but it doesn't. Actually it solves the problem I was having by only deploying things from context files in $CATALINA_HOME/conf/[engine_name]/[host_name], but doesn't deploy things from appBase. 2. Should the second action read "Any web application archive file <ins>within the application base directory</ins> that does not have a corresponding directory of the same name..." 3. The paragraph starting "In addition to the automatic deployment" doesn't mention the attribute "autoDeploy" but I think this is what it is referring to. 4. The last paragraph starting "When using automatic deployment," doesn't reflect the fact that if you upload a war file, the docBase attribute is ignored and the file goes in the appBase directory. Hence you get double deployment on restart unless you disable deployOnStartup I accept that this was in fact a configuration issue but hopefully the documentation can be made clearer. Thanks
OK, doc clarified (for 5.0.29 and 5.5.3).