Reputation: 4210
I have a webapp that is deployed as a WAR file to a Tomcat 6 server. It stores some data in a directory inside the app itself. These files get overwritten when a new version of the app is deployed, but it's trivial to back them up and re-add them.
However, one of my coworkers claims that Tomcat will sometimes spontaneously re-explode my WAR file, even if the exploded version is already there, and wipe out these files. I have never seen this behavior before. I can figure out a workaround for this if I really have to, but is this something that actually happens, either spontaneously or on server restart?
Upvotes: 3
Views: 2812
Reputation: 1108632
Tomcat will only autodeploy without restart whenever you have
<Host autoDeploy="true">
in your /conf/server.xml
and you edit one of the resources in the expanded WAR. But this setting is not really recommended for production environments as it may lead to memory leaks. This is also by default turned off.
That said, I strongly recommend to put that data you're talking about outside the WAR. If they are supposed to be part of the webapp's runtime classpath, just put them in a fixed disk file system path outside Tomcat, e.g. /var/webapp/config
and edit the shared.loader
property of /conf/catalina.properties
to specify that path:
shared.loader = /var/webapp/config
Those resources will then be available in the classpath the usual way. This way you don't need to backup and re-add it, which is plain clumsy and very error prone.
Upvotes: 6