Database config should not be hardcoded

Description

Currently, the database connection configuration is hard-coded in the web.xml file (which is replaced in production - to prevent the correct credentials from being in version control).

Instead, the connection configuration should be removed from the web application. It should obtain that configuration from the application server.

Application servers like Tomcat facilitate this by allowing configuration to be obtained through JNDI. We should add a database resource to the Tomcat context, which then gets used by the webapplication.

Environment

None

Activity

Show:
Guus der Kinderen
May 26, 2016, 2:31 PM

Note that there are differences between the 'old' Contegix environment and the 'new' EC2 environment, that affect the Tomcat context.xml configuration:

  • the Contegix environment uses Tomcat 5.5, while 8.0 is used on EC2. See http://tomcat.apache.org/migration-8.html#Database_Connection_Pooling for number of documented changes

  • On the EC2 environment, a YUM-managed Tomcat has been installed, which has different libraries than the installation on Contegix, which appears to have been based on a downloaded artifact straight from the Tomcat website. A notable difference is that on EC2, the default Tomcat DBCP library is not available. As a result, the DBCP-factory needs to be defined in the JNDI datasource (to prevent Tomcat from using the default factory for which no class is available).

  • The database host, name, and credentials differ on both environments.

A snippet like this should be added to the context.xml file on the EC2 host.

Guus der Kinderen
May 26, 2016, 4:20 PM

I've modified the source code to remove the configuration (from the webapp) as well as the mysql-specific libraries. I've modified both environments to have the configuration (in Tomcat) as well as the mysql-specific libraries. I've verified that after a redeploy and restart, both environments still write to the database.

Fixed

Assignee

Daryl Herzmann

Reporter

Guus der Kinderen

Labels

None

Expected Effort

None

Ignite Forum URL

None

Priority

Major