+1  A: 

You could, as part of your build process, create 4 differently named WAR files, each with the relevant DB configuration for a particular schema.

Once deployed to Tomcat, each WAR will be accessed by http://testserver:8080/WAR_name, so you will not have the conflict you describe.

William