Skip to main content

Why does tomcat like deleting my context.xml file? [Resolved]

I'm developing a web-based Java application at work and (obviously) have to run it locally during development. I've figured out the Tomcat docs and have a suitable context.xml file in /etc/tomcat6/Catalina/localhost/ but every so often, Tomcat decides to delete it! Which means I have to put it back and restart Tomcat.

Why does it do this? I have searched the Tomcat docs about it and am none the wiser.

(Oh yes: it's not actually called context.xml but owners.xml as that's the HTTP path prefix for this application.)


I've now seen Tomcat delete the file whilst Tomcat was running. I think I need to file a bug...

Question Credit: staticsan
Question Reference
Asked August 18, 2019
Tags: tomcat
Posted Under: Network
2 Answers

If you don't want autoDeploy feature, in production environments for instance, you may consider the following attributes in the conf/Catalina/localhost context file :

  • autoDeploy="false"
  • and deployXML="false"

autoDeploy="false" may not work alone because application context.xml (in META-INF) can override server.xml settings of autoDeploy.

  • The application's META-INF/context.xml will be used in development environment, with autoDeploy
  • The conf/Catalina/localhost context in production, without autoDeploy.

deployXML attribute documentation attribute documentation is worth reading (§ Standard Implementation).

Exhaustive autoDeploy user case, and when context is removed : i.e. application undeployed, user case is documented can be found here.

credit: Gabriel Glenn
Answered August 18, 2019

Cant answer the Why bit.

However, This link states you can stop this by setting the autoDeploy="false" in server.xml

credit: JoseK
Answered August 18, 2019
Your Answer