Learn. Share. Profit.

Main menu

Tag Archives: Java

The Tomcat Native Libraries improve the performance of Tomcat by leveraging the faster I/O capabilities of the operating system. This is a step-by-step procedure to install them with the least amount of difficulty. The native libraries will be built from source, so we need to make sure we have the required dependencies.

Alternately, you can use the Sun/Oracle JDK. In either case you will need to set the environment variable JAVA_HOME.
2. Download the latest native libraries from http://tomcat.apache.org
3. Untar the source tarball
# tar -zxvf tomcat-native-1.1.24-src.tar.gz

If the make fails, it maybe because it cannot find your installation of java. If you used my java.profile (look in my github repo for tomcat), it should have set the necessary environment variable. If it did not, your java install maybe in a location that the profile script does not search. Update your copy of the java.profile to reflect your location and log out and back in to refresh your environment variables. If JAVA_HOME is set and make still complains, then JAVA_HOME maybe pointing at an incomplete installation.

Once the native libraries are installed, you can use the commented lines in my setenv.sh to enable the tomcat server to locate these libraries. A restart of your tomcat instance should pickup the changes and when you review catalina.out, you should see that the server identified the libraries and used them.

The reason I override the prefix, is to keep the tomcat install clean, you can upgrade the native libraries without touching the tomcat instance and vice-versa.

Here’s a step-by-step guide to deploy Tomcat (6 or 7). I’ll use 7 for the rest of this guide but the procedure is the same regardless of the version. I try to avoid modifying the Tomcat install itself once deployed, so I redirect the configuration to an alternate location. This makes upgrades very simple and keeps all the important pieces in one place.

Start by cloning my github tomcat repo to get the files you need:
git clone git://github.com/breauxaj/model-tomcat.git

Among the files in the repo, tomcat.sh and java.sh, are intended to make things easier by setting some environment variables. Copy both files into /etc/profile.d/
# cp tomcat.sh /etc/profile.d/tomcat.sh
# cp java.sh /etc/profile.d/java.sh

In order for them to take effect, log out and back in. You should now see a TOMCAT_HOME, CATALINA_HOME and JAVA_HOME set. If JAVA_HOME is not set, you might not have java installed. You can use the openjdk version available with most RHEL-distros. If you want to use the Sun (Oracle) version, the java.profile should be able to find that one once it’s installed.

Let’s deploy Tomcat 7 on the host:
1. Download the tomcat source tarball from http://tomcat.apache.org/
2. Untar the tarball (usually best to do this in your home folder)
# tar -zxvf apache-tomcat-7.0.28