This library provides a Tomcat Property Source that reads property values from an external file.
- Download the latest version of the library using the link in the Maven Central badge at the top of this page.
- Copy the JAR file to the folder
${TOMCAT_HOME}/lib
- Configure Tomcat to use the property source provided by the library and specify the filename of the property file using the following Java system properties.
-Dorg.apache.tomcat.util.digester.PROPERTY_SOURCE=com.github.ncredinburgh.tomcat.ExternalPropertySource"
-Dcom.github.ncredinburgh.tomcat.ExternalPropertySource.FILENAME=tomcat.properties
Replace the value tomcat.properties
with the path of your file.
If a relative path is specified it will be resolved against the current working directory (system property user.dir
).
For more information on Tomcat property replacement and other system properties see the Tomcat Configuration Reference.
The property source allows the properties file to be stored in an encrypted form on disk for the purposes of security. During Tomcat startup the properties file is decrypted and used by Tomcat to perform property replacement. See Encryption Support for more details.
Any error encountered during the loading of the property source will be logged to the Tomcat log file $TOMCAT_HOME/logs/catalina.out
. Errors encountered during the loading of the property source do not prevent Tomcat starting. However, property values expected from the file will not be available.
The property source can write debug information to the Tomcat log file $TOMCAT_HOME/logs/catalina.out
by adding the following line to the Tomcat logging configuration file $TOMCAT_HOME/conf/tomcat.properties
:
com.github.ncredinburgh.tomcat.level = FINE
All contributions are welcome. Just fork this repository and send us a merge request. Just make sure your code meets the following requirements:
- You follow the Google Java Style Guide
- All the unit tests pass when running
mvn test
- 1.2 Added options to specify whether to keep or remove input file (to ease automation)
- 1.1 Added support for encrypted properties file
- 1.0 Initial release