The only way to configure Tomcat 7 in 2012

Java.. and things in its ecosystem… tend to be inspirational. For instance I recently had to use Tomcat to deploy and test a few applications. One of those required more than 128MB of heap memory. Yes, by default, Tomcat 7 loads up with a Java heap size limited to 128MB. So, increasing it should be easy, right? Just a few clicks away in the documentation on the official site, right?

Wrong.

In 2012, Tomcat does not seem have a configuration file in which this can be edited (when I Google for something more than 15min, and don’t find it.. it probably doesn’t exist).

So people tend to hack the catalina.sh script, that is used to start the server up. Which is wrong. The right way is to put all the customizations into a setenv.sh file – in the same folder as catalina.sh. Of course. Server configuration through shell script variables. Such intuitiveness and yet it’s the last place anyone would look. Of course, sarcasm…

So.. find your catalina.sh, create setenv.sh in the same directory and write something like this into it:

#!/bin/sh
export JAVA_OPTS=”-Xms256m -Xmx1024m”

This will set initial heap size to 256MB, and maximum to 1024MB. And there you have it. Additional usable shell variables, uh.. I mean configuration options, are listed in the beginning of the catalina.sh, commented out with descriptions.

One thought on “The only way to configure Tomcat 7 in 2012

  1. in my console show this message:
    [tomcat@snv bin]$ /opt/tomcat/bin/setenv.sh: línea 2: export: `-Xmx1024m’: no es un identificador válido

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s