Ubuntu: Installing Apache Portable Runtime (APR) for Tomcat

After reading “Introducing Apache Tomcat 6? presentation by Mladen Turk I decided to enable Apache Portable Runtime (APR) native library for Tomcat.

It was supposed to be as easy as

sudo ./configure
sudo make
sudo make install

but as you may guess, it was a little bit more than that.

1. Installing Apache APR.

Most Linux distributions will ship packages for APR” – those of Linode don’t, I had a barebone Ubuntu 10.10 box without even “gcc” and “make”, let alone Apache APR. Thanks God, networking was not an issue, unlike last time.

wget http://apache.spd.co.il/apr/apr-1.4.5.tar.gz
tar -xzf apr-1.4.5.tar.gz
rm apr-1.4.5.tar.gz
cd apr-1.4.5/
sudo apt-get install make
sudo ./configure
sudo make
sudo make install

2. Installing Tomcat Native.

wget http://off.co.il/apache//tomcat/tomcat-connectors/native/1.1.20/source/tomcat-native-1.1.20-src.tar.gz
tar -xzf tomcat-native-1.1.20-src.tar.gz
rm tomcat-native-1.1.20-src.tar.gz
cd tomcat-native-1.1.20-src/jni/native
sudo ./configure --with-apr=/usr/local/apr

The result was

checking build system type... x86_64-unknown-linux-gnu
..
checking for APR... yes
..
checking for JDK location (please wait)... checking Try to guess JDK location... configure: error: can't locate a valid JDK location

Ouch! “Can’t locate a valid JDK location” ? On my machine?

$ which java
/home/user/java/jdk/bin/java
$ echo $JAVA_HOME
/home/user/java/jdk
$ java -version
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)

But for some reason “tomcat-native-1.1.20-src/jni/native/configure” script didn’t see my “JAVA_HOME” variable no matter what and even installing sun-java6-jdk” didn’t help much. After patching the “configure” script to dump locations it was looking for “valid JDK” I had:

..
configure: [/usr/local/1.6.1]
configure: [/usr/local/IBMJava2-1.6.0]
configure: [/usr/local/java1.6.0]
configure: [/usr/local/java-1.6.0]
configure: [/usr/local/jdk1.6.0]
configure: [/usr/local/jdk-1.6.0]
configure: [/usr/local/1.6.0]
configure: [/usr/local/IBMJava2-1.6]
configure: [/usr/local/java1.6]
configure: [/usr/local/java-1.6]
configure: [/usr/local/jdk1.6]
configure: [/usr/local/jdk-1.6]
..

Ok then, here you have it now:

sudo ln -s ~/java/jdk/ /usr/local/jdk-1.6
sudo ./configure --with-apr=/usr/local/apr
sudo make
sudo make install

And with

..
export LD_LIBRARY_PATH='$LD_LIBRARY_PATH:/usr/local/apr/lib'
..

I now had a beautiful log message in “catalina.out“:

..
Mar 7, 2011 11:51:02 PM org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded APR based Apache Tomcat Native library 1.1.20.
Mar 7, 2011 11:51:02 PM org.apache.catalina.core.AprLifecycleListener init
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
Mar 7, 2011 11:51:03 PM org.apache.coyote.AbstractProtocolHandler init
..

As soon as “evgeny-goldin.org” moves to its new location on the brand-new Linode box it will benefit from this performance optimization. I’ll describe the migration process and reasons for it a bit later, once it is done.

Reference: Ubuntu: Installing Apache Portable Runtime (APR) for Tomcat from our JCG partner Evgeny Goldin at the Goldin++ blog.

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

JPA Mini Book

Learn how to leverage the power of JPA in order to create robust and flexible Java applications. With this Mini Book, you will get introduced to JPA and smoothly transition to more advanced concepts.

JVM Troubleshooting Guide

The Java virtual machine is really the foundation of any Java EE platform. Learn how to master it with this advanced guide!

Given email address is already subscribed, thank you!
Oops. Something went wrong. Please try again later.
Please provide a valid email address.
Thank you, your sign-up request was successful! Please check your e-mail inbox.
Please complete the CAPTCHA.
Please fill in the required fields.

Leave a Reply


four × = 12



Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy | Contact
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
Do you want to know how to develop your skillset and become a ...
Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

Get ready to Rock!
You can download the complementary eBooks using the links below:
Close