Build one ear or war for UAT and Production
If you build a single war or ear file that can be deployed to your user acceptance (UAT) server and then to your production server, you guarantee that the war or ear file you tested is exactly the same as the one deployed to production. If you do separate builds for UAT and production, there is always the chance that an untested mod sneaks in.
To achieve this, you need separate servers for UAT and production. Setup the datasources on the UAT box to have exactly the same JNDI names as the ones for production (e.g. jdbc/datasource1), just pointing to your test database, not your production one. You can leave the context root of the web application unchanged, as the UAT and production servers are different. If you are using web services, you can store their URLs in a database table so that the UAT database contains the URL for testing and the production database contains the URL for production.
If you don't have a separate development environment, you can deploy development code to the UAT server, but you will need to parameterise your build:
- Context root.
- Datasource JNDI names.
- Any web services or external URLs.