Compiling Tomcat APR-Native on OEL5.2

This is just a short tutorial on how to compile APR on Oracle Enterprise Linux 5.2. If you ever need to install Apache Portable Runtime on a Oracle Enterprise linux machine, Then this is what you need, and how to configure it.

Sorry this is a personal note type of tutorial, something not clear? Then please ask me using a comment.

I have taken the time to make the required packages for OEL5.2 i386 (RH EL5.2) available inside a tar.gz archive. Please follow the portion below if you have wget, or upload it yourself using the url after the wget command;

cd ~
mkdir rpms
cd rpms
wget "http://technology.amis.nl/download/Other/apr_rpms/apr_oel52_i386.tar.gz"
tar -xf ./apr_oel52_i386.tar.gz

Rgrds, and hope this one helps you out!

## Distro : Oracle Enterprise Linux 5.2 Carthage
## Required packages
#
# gcc-4.1.2-42.el5.i386.rpm
# glibc-devel-2.5-24.i38</em><em>6.rpm
# glibc-headers-2.5-24.i386.rpm
# libgomp-4.1.2-42.el5.i386.rpm
# kernel-headers-2.6.18-92.el5.i386.rpm
#
# apr-devel-1.2.7-11.i386.rpm
# apr-1.2.7-11.i386.rpm
#
# postgresql-libs-8.1.11-1.el5_1.1.i386.rpm
#
# apr-util-devel-1.2.7-7.el5.i386.rpm
# expat-devel-1.95.8-8.2.1.i386.rpm
# openldap-devel-2.3.27-8.el5_1.3.i386.rpm
# db4-devel-4.3.29-9.fc6.i386.rpm
# cyrus-sasl-devel-2.1.22-4.i386.rpm
# apr-util-1.2.7-7.el5.i386.rpm</em>


## Install the GCC compontents if you haven’t already...
rpm -ihv gcc-4.1.2-42.el5.i386.rpm glibc-devel-2.5-24.i386.rpm libgomp-4.1.2-42.el5.i386.rpm glibc-headers-2.5-24.i386.rpm kernel-headers-2.6.18-92.el5.i386.rpm

## Install APR
rpm -ihv apr-devel-1.2.7-11.i386.rpm apr-1.2.7-11.i386.rpm

## Install the postgresql libs for required libpq.so.4
rpm -ihv postgresql-libs-8.1.11-1.el5_1.1.i386.rpm

## Install the APR-util-devels
rpm -ihv apr-util-devel-1.2.7-7.el5.i386.rpm expat-devel-1.95.8-8.2.1.i386.rpm openldap-devel-2.3.27-8.el5_1.3.i386.rpm db4-devel-4.3.29-9.fc6.i386.rpm cyrus-sasl-devel-2.1.22-4.i386.rpm apr-util-1.2.7-7.el5.i386.rpm

## Locate the tomcat native tar.gz archive.
## Unpack the tar.gz</em>
export mRES=`find / -name "tomcat-native.tar.gz"`;
export mPAT=`dirname $mRES`;
cd $mPAT;

#unpack the tomcat package.
tar -xf ./tomcat-native.tar.gz

#You should do this manually locate the apr binairy and the jdk directory. Use these in your ./configure script thats in the native source dir.
find / -name "jni_md.h"

# Copy the path up till the java version and strip the /includes/linux. The path
# you are looking for should look somewhat like this;
# /opt/jdk#.#.#_##/
# from the result
# /opt/jdk#.#.#_##/includes/linux

#Locate the APR binairy.
export mRES=`find / -name "apr*config"`;
export mPAT=`dirname $mRES`;
cd $mPAT;

#Look for the directive /usr/bin/apr-1-config copy rename the file into the
#same directory using the name apr-config like;
cp ./apr-1-config ./apr-config
#This is because the configure script looks for the apr-config binairy.</em>

## Finanly Run the configure script inside the APR-native directory.</em>
./configure --with-apr="/usr/bin/" --with-java-home="/opt/jdk#.#.#_##/"

## Link and compile if all is successfull ##
make 
make install

## Tell Catalina where the libs are (posted after the make install) ##
cd /path/to/your/tomcat/bin
vim catalina.sh

#Add -Djava.library.path=/usr/local/apr/lib in the JAVA_OPTS="" directive..
export JAVA_OPTS="-Xms512m -Xmx1024m -XX:MaxPermSize=512m -server -XX:+AggressiveOpts -Djava.library.path=/usr/local/apr/lib "

#Save the settings and restart tomcat.
service tomcat restart
/etc/init.d/tomcat restart

#You should be able to use APR now.

About Chris Gralike

Momenteel ben ik manager van de afdeling business continuity bij de zakelijke IT dienstverlener AMIS Services BV. Sinds 2003 ben ik actief in de ICT branche. Tussen 2003 en nu heb ik verschillende rollen vervuld. In de rollen: systeem- en netwerkbeheer, system engineer, servicemanager en nu practice manager ben ik in contact gekomen met uiteenlopende technologieën, methodologieën, ideeën, oplossingen en innovaties. Een rijke ervaring waarmee ik de klanten van Conclusion en AMIS elke dag probeer te ondersteunen. Mijn credo: 'Altijd opzoek een win-win tussen business en technologie.'

Posted on January 5, 2010, in Linux, Linux Commands, Tomcat and tagged , , , , , , , , , , , , . Bookmark the permalink. 1 Comment.

  1. Ow.

    Make sure not to mix the 64Bits / 32Bits libs.

    If you are using an 32Bits JVM, make sure you also compile / use the 32Bits APR libs.

    You can check the lib type by using the following command..
    [root@tomcathost ~]# cd /usr/local/apr/lib
    [root@tomcathost lib]# file libapr-1.so.*
    libapr-1.so.0.4.2: ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped

    This means the JVM should also be 64Bits, Else you will get “Couldnt find apr in path… ” errors inside your Catalina.out logfile.

    -Hope this helps🙂

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

%d bloggers like this: