Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Separate web.xml for development and production

My web.xml is different in devel and production environments. For example in development environment there is no need in security constraints.

Typically I deploy new application version as follows:

  1. Export Eclipse project to WAR.
  2. Upload WAR to the server.
  3. Redeploy.

The problem is that I have to manually uncomment security constraints in web.xml before exporting.

How do you solve this problem?

I also met an opinion in some articles that "web.xml is rarely changed". But how can web.xml not change if it is exported to WAR on every update?

Thanks in advance!

like image 707
Andrey Minogin Avatar asked Nov 29 '09 16:11

Andrey Minogin


Video Answer


1 Answers

If you can't use the same web.xml during development, I would automate the build process, use two web.xml and bundle the "right" one at build time depending on the targeted environment as Brian suggested. But, instead of Ant, I'd choose Maven because it will require less work IMHO and it has a built-in feature called profiles that is perfect to manage environment specific stuff like here.

In other words, I'd put the build under Maven 2 and use a production profile containing a specific maven-war-plugin configuration to build a WAR containing a web.xml having the required security constraints. Another option would be to merge the development web.xml (cargo can do that) to add the security-constraints but this is already a bit more "advanced" solution (a bit more complex to put in place).

like image 155
Pascal Thivent Avatar answered Sep 20 '22 23:09

Pascal Thivent