Category Archives: tomcat

Getting tomcat to stop deleting your context xml files

I’ve been plagued with this annoying problem in tomcat for about a year, and it has been driving me crazy. I’ve looked through the code, joined the mailing list, etc. etc. The problem is when you have context xml files, such as /usr/local/tomcat/conf/Catalina/localhost/app.xml. Generally, you would use such files to set up JNDI data sources for database connections, but I also use them to set up configuration beans in order to keep environment-specific data outside of your application code (which I consider the whole war file to be). Anyway, tomcat seems to randomly delete those files when I change anything in the application files. I tried various configurations using war files, no war files, and war files in funny locations, and it happened to all of them.

I never did find out why it deletes the files, but I did find a solution, thanks to a user on the tomcat mailing list. All you have to do is turn off “autoDeploy” on the “Host”. Basically, you need to edit /usr/local/tomcat/conf/server.xml and change the xml element, so that it says autoDeploy=”false” instead of autoDeploy=”true”. And with that, all my problems are over.

Advertisements