Apache Tomcat and APR in a Linux Server

When you do a fresh installation of Apache Tomcat, you'll notice the following error message in the logfile:

 

org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in
production environments was not found on the java.library.path


APR stands for Apache Runtime Portable Project which provides a consistent API to the native environment where the application server is running (either Linux, Windows, etc).  This means that Tomcat itself contains this native library, but it is disabled by default, since you need to install first the APR.

 

It is recommended to perform the following steps as root or a sudoer user, since you need access to common and restricted resources in the server

To install the APR, first move the Tomcat Native Library to a common location:

cp $TOMCAT_HOME/bin/tomcat-native.tar.gz /usr/local/src/

Then, download the APR library from Apache's site and install it in /usr/local/src

cd /usr/local/src
tar -zxvf apr-1.3.9.tar.gz
cd apr-1.3.9
./configure
make all install

This will install the APR libraries at /usr/local/apr.

After this, install Tomcat's native library:
 cd /usr/local/src
tar -zxvf tomcat-native.tar.gz
cd tomcat-native-*-src/jni/native/
./configure --with-apr=/usr/local/apr/bin/apr-1-config
make all install 


After this, you only need to tell Tomcat where to find these libraries.  One option is to use the LD_LIBRARY_PATH environment variable:

 export LD_LIBRARY_PATH=/usr/local/apr/lib 


Or create some symbolic links in the J DK used by Tomcat

After this, restart tomcat and you should see the following message in the log file:

 INFO: Loaded APR based Apache Tomcat Native library 1.1.16. 

 

Comments (0)