0

I have a java webapp running under Tomcat 7 behind IIS 8 (both are configured for multihost).

To update the web application, I usually undeploy the existing one and deploy a new WAR (which gets exploded in its folder structure), but this causes the IIS web.config file to be erased, thus loosing all the (IIS) website settings.

As far as I can tell (but I'm new to IIS), in IIS the website physical path is the webapp ROOT folder (i.e. /path/to/tomcat/webapp/ROOT exploded from the WAR named ROOT.war) and when I configure an error page in IIS, the file ROOT/web.config is created.

Is there any way to avoid losing that configuration file? Or should I always redeploy the new war without undeploying the web application first?

If necessay, here are a couple of details:

  • my web application has nothing to do with the web.config file, it is read and written by IIS only;
  • IIS and Tomcat are connected with the BonCode connector;
  • the BonCode connector is installed for all sites;
  • I'm running only one Tomcat instance;
  • I'm changing IIS configuration to set custom error pages and SSL requirements.
watery
  • 5,026
  • 9
  • 52
  • 92

1 Answers1

0

When you deploy a a war in tomcat, lets say your war is called MyWar.war, the folder MyWar is created and it replaces anything in there. Sometimes it is a good practice, like in your case, to have configuration files read from outside the war (config files that you dont want to override). If you can access your code and compile/redeploy you will be able to do this. What you have to do is re write the code from where you read your web.config and try to read it as an external File Resource (FileInputStream) instead of an ResourceAsStream (which is likely how you are reading your config file).

This way everytime you deploy, it doesn't matter if you re deploy and override your ROOT folder, because config will be always read from outside.

An Example of how to do this is in this POST I also answered.

Loading Properties from a JAR file (java 1.6)

Hope it helps

Community
  • 1
  • 1
Cesar Villasana
  • 681
  • 3
  • 6
  • One small clarification: the *web.config* is an IIS read and written file, my web application has nothing to do with it. The best would be to move it somewhere else, but I have no idea if this is even possible. – watery Oct 01 '14 at 16:28
  • Oh ok. Well I suppose there must be someplace where you can edit IIS configuration and specify location of your config files. If this cannot be done (I dont know because I havent used IIS before) then you would have to make a copy of your file, save it someplace else and if you have to redeploy tomcat, deploy and then replace the file with the one you saved. – Cesar Villasana Oct 01 '14 at 16:37