Random Tomcat Annoyance

by Charles Miller on April 1, 2005

Every tomcat host configuration has a "webapps" directory. By default, web applications dumped into this directory are automatically deployed. So if you put an application into webapps/foo, it will be deployed as http://www.example.com/foo

Simple enough so far.

Tomcat host configurations also allow you to specify web applications explicitly using Context declarations. You add a Context tag, point the docBase parameter at the root of your web application, and voila.

This is where the fun begins.

  • By default, docBase is relative to the webapps directory
  • If something is in webapps and specified in a Context, it is deployed twice: once for the automatic deployment and once for the manual.

It's a subtle useability issue. Every default behaviour or configuration tells the user "this is how the application expects to be used". So if you default to auto-deploying anything placed in a certain directory, and you default to looking for manually deployed applications in the same directory, you're creating an affordance for a broken configuration.

The fact that the fix is dead simple (deploy the app elsewhere, or turn off auto-deployment), and it's a documented problem doesn't make it any less of a bad design decision.

Previously: Memory Management

Next: Programming Metaphors