3
votes

I'm developing a webapp using Apache Tomcat. This webapp will be deployed in a server which hosts other webapps. Now, since my webapp requires the user to authenticate, I'd need to modify some files in the "conf" directory of Tomcat such as "tomcat-users.xml". The problem is that these files are shared with the other webapps. Is there a way to have a "conf" directory for my webapp which is separated from the shared one? Thank you.

1

1 Answers

3
votes

Tomcat allows you to separate out configuration from the main server.xml by creating an xml file underneath $CATALINA_BASE/conf/[enginename]/[hostname] called [YourWebappName].xml.

For example: $CATALINA_BASE/conf/Catalina/localhost/PetClinic.xml

This file bascially contains a <Context> element defining the webapp specific context configuration. In here you can define your own webapp specific realm with the necessary authentication parameters for your app.

This mechanism is designed so that you can modify webapp specific configuration without touching the top-level shared files in Tomcat's conf folder.