I am working with an ancient legacy web app which I need to prepare for continuous integration by separating resource configuration from the app itself (so that we can make a single WAR file that works on every environment assuming config file presence in some predetermined filesystem locations outside the app server).
Unlike our other, more modern web apps that use a Spring
context, this one gets its database configuration via app server context and it is located in META-INF/context.xml
, which looks something like
<?xml version='1.0' encoding='utf-8'?>
<!--
Context configuration file for the Tomcat Administration Web App
-->
<Context docBase="axis2" reloadable="true" crossContext="true">
<Resource
name="jdbc/GWSDEV"
auth="Container"
type="javax.sql.DataSource"
factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
username="myuser"
password="mypasswd"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://my.server.com/mydb"
maxActive="100"
maxIdle="30"
maxWait="10000" />
</Context>
I would like to move this config somewhere outside the Tomcat app and reconfigure the app to load a properties file from something like /etc/myancientapp/datasource.props
so that I can build a single WAR file without embedded config in Jenkins and deploy the same war in every environment and not have to build a separate one for each environment differing only in that one file. Then the config would be different in every environment but I can live with a fixed path (/etc/myancientapp/datasource.props).
How can I separate this configuration out of my app and replace it with a pointer to a config file that is to be loaded from outside the app?