Hi Angelo,
i know the problem you're talking about exactly
I'm still not sure what would be the best way to externalize such configuration properties completely to be able to deploy the same WAR file on any server without having to modify the content of the WAR itself.
I guess one clean way would be to use a JNDI lookup inside your application in order to retrieve database configuration parameters etc. Every application server or
servlet container offers a way to provide information via JNDI lookups to applications running inside of it.
So you could always use the same JNDI lookup key (e.g. "jdbc/yourDatabase") inside your application and configure the container/server to provide the correct information via this key. This way you don't have to modify the application itself but instead you use the application server facilities to configure which information should be provided via this lookup key. This should be enough for typical use cases I think. For example if you have an application server for
testing you usually want to use a test database together with it. From your application's view this doesn't make any difference because the JNDI key would be the same. All that you or an administrator would have to do is to configure the application server to provide configuration parameters for the correct database etc.
I hope this was more or less clear
But I'm sure there are other ways to configure a web application without having to modify the application itself. Even though Maven profiles would be a solution to easily build different WARs I'd still be interested to hear about other ideas.
Marco