Hi, On 29 October 2012 11:35, Anurag Kapur <anuragka...@gmail.com> wrote: > Hi, > > I have a few WAR files provided by a supplier where there are environment > specific configurations in files that cannot be moved outside the web > application (It is possible, but since I do not have the source code, I > cannot do it and this looking for options while the suppliers does this at > their own pace) > > Example: > > MyWebapp > |___________WEB-INF > |___________config.xml > > For our build and release process, I would have liked to build a single > environment agnostic .war file for MyWebapp and deploy configurations like > config.xml to a folder outside the web app but in the classpath. But due to > the reasons mentioned above this isn't possible for now. So my options: > > 1. Build environment specific .war files example: > MyWebapp-Dev.war, MyWebapp-TEST.war, MyWebapp-PROD.war > This works, but I am looking for better options > > 2. Have a mechanism by which I have a way of getting notified by Tomcat > when the .war is deployed so that I can then copy the environment specific > files into the exploded WAR. I know I can wait for say 30 secs after > dropping the .war file to the Tomcat_HOME/webapps directory for it to be > exploded and then copy my configs. However, this method can be error prone > on frequent deployments as Tomcat might take longer than the wait time I > configured (No, I cannot set a very large and hence always safe wait time). > Is there a better way of doing this?
Instead of deploying a .war file, deploy an exploded webapp outside of Tomcat's directory structure. Then place the relevant context.xml inside conf/Catalina/localhost dir representing your webapp. (e.g. example.xml for a context of /example) This way you can completely control when the application is deployed and when tomcat is stopped / started via your own deployment scripts as well as ensuring the config.xml is in the right place before the application is restarted or Tomcat is (re)-started Depending upon your setup you may need to disable automatic deployment. http://tomcat.apache.org/tomcat-7.0-doc/config/context.html Be sure to use a "docBase" that is outside of Tomcat's directory structure. Note also the use of versioned contexts (example##<versionnumber>.xml) can be quite useful here in minimising downtime. > > -- > Anurag Kapur > > Twitter: @anuragkapur <http://www.twitter.com/anuragkapur> > AboutMe: http://www.anuragkapur.com -- Best Regards, Brett Delle Grazie --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org