06 March 2008

Tomcat Deploys My Application Twice !

I drop my foo.war under webapps, and from the logs I see objects from my Spring application context getting loaded two times. What's causing this double deployment?

After much head-scratching I realised that my foo app was getting deployed as the root context (under "/"), as well as under "/foo". And in our Tomcat's server.xml we had a little

  <Context path=""
              docBase="/path_to_tomcat/webapps/foo"
              reloadable="true" 
              crossContext="true"> 
  </Context>

We dumped this Context entry, renamed foo.war to ROOT.war (caps necessary), and our double application startup disappeared.

Tomcat was dutifully doing its auto-deploy magic with its webapps directory, and then dutifully deploying any Contexts it found in its server.xml. If you really need a Context in your server.xml, make sure its docBase isn't under your Tomcat's webapps directory.

A simple solution, but it took us a while to fix, and according to my friend google lots of other people have had similar symptoms and worse trouble fixing them.

HTH :))

1 comment:

Note: Only a member of this blog may post a comment.