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.)
Update
I've now seen Tomcat delete the file whilst Tomcat was running. I think I need to file a bug...
Quick summary: there are several conditions (like changing the war file, deleting the webapp or replacing it with new content) under which tomcat will undeploy the context including removing the context file.
Details: Whether tomcat does or doesn't do autoDeployment (means checking for changes in your .xml descriptor as well as checking changes in the webapp directory) is driven by:
server.xml localted in $CATALINA_HOME/conf/server.xml section:
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
You can also set this property in your context file overloading the value
Quoting the doc for cases when autoDeploy=true may cause removal of your context file:
Exhaustive details: http://tomcat.apache.org/tomcat-6.0-doc/config/host.html#Automatic%20Application%20Deployment
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" may not work alone because application context.xml (in META-INF) can override server.xml settings of 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.
Cant answer the Why bit.
However, This link states you can stop this by setting the
autoDeploy="false"
inserver.xml
I honestly dont know what the reasoning behind Tomcat doing this is but try adding the following XML attribute to your context element
So your context could look something like this:
This should keep Tomcat from deleting the file
I realize this is an old thread, but I thought I would share what I found to fix this problem...
I had been having the exact same issue with my context.xml file for my desktop version of tomcat getting clobbered every time that I would deploy a new copy of the war file for my application.
The problem was due to the fact that I was making changes to this file directly on the filesystem. What fixed the problem was to edit the context.xml file via my Eclipse editor. Inside of my Eclipse, there's a "servers" project that once you expand it, you can see a handful of files, such as context.xml and server.xml. It appears that if you modify the files from here instead of going out to the filesystem, your changes are kept.
I found this solution in the following thread: https://www.liferay.com/community/forums/-/message_boards/message/16511799
I hope this helps someone else!
-StephenS
The general issue as described by the title is covered by Re-deploy from war without deleting context which is still an open issue at this time.
There is an acknowledged distinction between re-deploy which does not delete the context, and deploy after un-deploy where the un-deploy deletes the context. The documentation was out of date, and the manager GUI still does not support re-deploy.
Sometimes it is necesary have different values for app in the server, for example a path to store uploaded files. In developer environment mabe we have something like this:
But in server the path is different:
I also have the same problem, tomcat deleting the context.xml( meapp.xml ) from conf/Catalina/localhost
To solve I use context.xml.default, in the same path I create a file called context.xml.default and inside a put config I want to held:
So ,when redeploying then app, the confir parameteres still there.