Justin Skiles
Justin Skiles

Reputation: 9523

Tomcat 6 and updating context.xml on deployment

I'm using:

Here's my context.xml and web.xml structure in my web application project:

When I generate a WAR file for my application, context.xml is being packaged as expected. When I copy the WAR file to the Tomcat webapps folder and start Tomcat, the WAR file is extracted and context.xml is copied to \conf\Catalina\localhost\<webappname>.xml as expected. However, this only works if <webappname>.xml doesn't already exist. Therefore, I cannot make an update to context.xml, package the WAR, and redploy without first deleting the existing <webappname>.xml. I know this is the intended functionality based on reading the documentation.

My question is, what do I do then? How can I make updates to context.xml and have those updates copied automatically as if they were brand new? I don't want to have to delete <webappname>.xml before each publish.

Maybe I'm going about this the wrong way?

Upvotes: 1

Views: 2087

Answers (1)

Chris White
Chris White

Reputation: 30089

If you undeploy the application first, the .xml file will be removed from the conf/Catalina/localhost folder. Just dropping a new war in place however does not trigger a undeploy (just a deploy), and the old xml file will not be replaced.

You can undeploy the app by either:

  • Deleting the war file in the webapps folder - tomcat will undeploy the app (if autoDeploy is set to true in your server.xml for the Host configuration)
  • If you have the manager application installed, you can issue a delete/remove/undeploy command on the application, or there might be a 'undeploy' option when uploading a new war (i can't remember for sure which one it is)

Upvotes: 5

Related Questions