Tomcat Admins: Automate your configuration changes


Apache Tomcat is the right sized application server for web applications. It does not have the bloat and complexity of Java EE application server and continues to be light weight and efficient.

While Tomcat provides basic deployment capabilities, configuring Apache Tomcat instance for applications is a manual, error prone and repetitive process. When we launched Tcat Server, our goal was to make it extremely easy to use Tomcat in enterprises. I want to discuss one of the powerful features of Tcat Server that goes a step beyond making Tomcat easy to use – it helps you automate repetitive configuration tasks.

Server profiles in Tcat Server is the easiest way to group multiple Tomcat configuration files, dependent lib files and environment settings for the applications that you deploy.

For example, lets say web application you are deploying requires a third party library to be present in the lib directory under Tomcat. In addition, it also requires changes to context.xml file to insert a valve, and it requires that the initial heap size is atleast 512 MB.

The way you would do this in Tomcat is as below:

For each server that this app is being deployed to, repeat the following:

1. Manually copy the required lib file into Tomcat lib directory

2. Edit the context.xml file to make necessary modifications to include the valve

3. Depending on your operating system, set the environment variable

4. Restart the server

Lets say you are deploying your webapp onto 10 Tomcat instances – thats 40 steps.

Doing this on multiple servers is both time consuming, error prone and boring.

Wouldn’t you want a better way to do this? Presenting Server Profiles.

Here is how you do it using Server profiles:

Step 1: Create a work space to hold your lib file and modified context.xml file

Workspace holds the files required for profiles

Step 2: Create a profile, give it a name – in this case, lets call it ‘MySalesProfile’

Step 3:  Enter desired value for JAVA_OPTS under environment variables ( remember your webapp requires atleast 512 MB of heap size )

Sales Profiles include files ( config, libs ) and environment variables required prior to deploying sales applications.

Step 4: Select all the servers on which you want to make the configuration changes before deploying web application and apply Profile

Set profile for multiple servers at once.

Step 5: Restart all these servers, so JVM start parameters such as JAVA_OPTS take effect ( you can restart multiple servers from the console with a single click ).

Now you are done with necessary configuration changes needed prior to deploying a web application.  Oh, and one more advantage is when you need to add additional servers to support increasing load, all you have to do is apply this profile to the newly added server.

Try it out for yourself by downloading Tcat Server for free.

We'd love to hear your opinion on this post

3 Responses to “Tomcat Admins: Automate your configuration changes”

  1. This looks pretty cool. I want to use server profile to deploy a context file in conf/Catalina/localhost direcotry. Is there a way to make the maven-publish-plugin to set the published artifact to match the context? I guess I am a little lost how to link them together.

    • Hi Alex,

      Thank you for your comment.

      Some of the options for pushing out context file are:

      1. Make that context file part of your profile by uploading it to the repository under the profile workspace and when you apply that server profile to a server, that file will be pushed to the server.
      2. Using Maven plug-in, you can upload the webapp to the repository and then you can use the scripting in the Adminshell to do the deployment and also push out the context file
      3. Use the Files interface in the console to upload the context file

      If you want to do this programmatically, check out the REST api for access to files here:

      Hope this helps.

  2. I noticed that there is a “context path” column in “Deployment” package. But it’s empty. How can it be set to the context path that matches the context file.