The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path

s-n-2 picture s-n-2 · Mar 18, 2017 · Viewed 21.6k times · Source

When I debug tomcat, the broswer start but get 404:

HTTP Status 404 - /

type Status report

message /

description The requested resource is not available.

Apache Tomcat/7.0.75

The Tomcat Catalina Log and Server Log all have this below error:

The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /Users/luowensheng/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.

I searched SO, find a similar post:

What does "The APR based Apache Tomcat Native library was not found" mean?

My software environment is:

Mac OS 
IntelliJ IDEA

Answer

Ghayel picture Ghayel · Mar 18, 2017

HTTP Status 404 - /

This error is caused due to many problems for example:

  1. Mostly this error is thrown due to invalid path. make sure the following folders exists:
>  $cataline_home/webapps/your-project|
>                                         -->html,css,images, etc.                                       
>                                         -->WEB-INF|
>                                                    -->classes (your java files)
>                                                    -->lib     (your libraries)
  1. Make sure java is install on your machine. You can check it by running simply javac on command prompt or using java -version
  2. You are typing wrong URL address or incomplete URL or URL without tomcat port
  3. Also make sure you added your classes properly in web.xml file

installing Tomcat APR in MAC is HERE and for Linux following is tested by myself

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

Prerequisites for installing APR APR library APR-util library OpenSSL library

yum install openssl-devel
yum groupinstall "Development Tools"

mkdir tomcat-apr
cd tomcat-apr
wget http://www.us.apache.org/dist//apr/apr-1.5.2.tar.gz
tar -zxvf apr-1.5.2.tar.gz
cd apr-1.5.2
./configure
make
make install

The default installation path is /usr/local/apr

Download and Install APR-util                  
wget http://www.eu.apache.org/dist//apr/apr-util-1.5.4.tar.gz
tar -zxvf apr-util-1.5.4.tar.gz
cd apr-util-1.5.4
./configure --with-apr=/usr/local/apr
make
make install

The default path of installation is /usr/local/apr/lib Install JNI Wrapper for APR used by Tomcat (libtcnative)

cd $CATALINA_HOME/bin
tar -zxvf tomcat-native.tar.gz
cd tomcat-native-1.1.29-src/jni/native
./configure --with-apr=/usr/local/apr --with-java-home=/var/java/jdk1.7.0_45
make
make install

The native libraries were installed in /usr/local/apr/lib Integrate APR with Tomcat There are two ways to set Tomcat integrate with APR.

One is you can add the following parameter when start up the Tomcat in bin/catalina.sh: CATALINA_OPTS="-Djava.library.path=/usr/local/apr/lib"

The other is to add a new environment variable LD_LIBRARY_PATH in /etc/profile:

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

Then makes it effect via:

source /etc/profile 

After restarting the Tomcat service, we can get the following message in catalina.out log if APR was installed successfully.

Oct 07, 2015 8:08:54 AM org.apache.catalina.core.AprLifecycleListener init INFO: Loaded APR based Apache Tomcat Native library 1.1.29 using APR version 1.5.2. Oct 07, 2015 8:08:54 AM org.apache.catalina.core.AprLifecycleListener init INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].