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 :))

2 comments:

  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Java Online Training from India . Nowadays Java has tons of job opportunities on various vertical industry.

    ReplyDelete