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

EclipseTomcatApr

Eclipse Problem Overview


I am using Tomcat 7 in Eclipse on Windows. When starting Tomcat, I am getting the following info message:

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

What does this mean and how can I provide the APR library?

Eclipse Solutions


Solution 1 - Eclipse

It means exactly what it says: "The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path"

The library referred to is bundled into an OS specific dll (tcnative-1.dll) loaded via JNI. It allows tomcat to use OS functionalities not provided in the Java Runtime (such as sendfile, epoll, OpenSSL, system status, etc.). Tomcat will run just fine without it, but for some use cases, it will be faster with the native libraries.

If you really want it, download the tcnative-1.dll (or libtcnative.so for Linux) and put it in the bin folder, and add a system property to the launch configuration of the tomcat server in eclipse.

 -Djava.library.path=c:\dev\tomcat\bin

Solution 2 - Eclipse

Unless you're running a production server, don't worry about this message. This is a library which is used to improve performance (on production systems). From Apache Portable Runtime (APR) based Native library for Tomcat:

> Tomcat can use the Apache Portable Runtime to provide superior > scalability, performance, and better integration with native server > technologies. The Apache Portable Runtime is a highly portable library > that is at the heart of Apache HTTP Server 2.x. APR has many uses, > including access to advanced IO functionality (such as sendfile, epoll > and OpenSSL), OS level functionality (random number generation, system > status, etc), and native process handling (shared memory, NT pipes and > Unix sockets).

Solution 3 - Eclipse

On RHEL Linux just issue:

yum install tomcat-native.x86_64

/Note:depending on Your architecture 64bit or 32bit package may have different extension/

That is all. After that You will find in the log file next informational message:

INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].

All operations will be noticeably faster than before.

Solution 4 - Eclipse

Installation the native library on Ubuntu server with:

sudo apt-get install libtcnative-1

If that does not work tomcat-native needs to be installed

  1. Install Oracle java7:

    • sudo add-apt-repository ppa:webupd8team/java
    • sudo apt-get update
    • sudo apt-get install oracle-java7-installer
    • sudo apt-get install oracle-java7-set-default
  2. Install tomcat apr:

  3. Install tomcat tomcat-native:

Solution 5 - Eclipse

I just went through this and configured it with the following:

Ubuntu 16.04

Tomcat 8.5.9

Apache2.4.25

APR 1.5.2

Tomcat-native 1.2.10

Java 8

These are the steps i used based on the older posts here:

Install package

sudo apt-get update
sudo apt-get install libtcnative-1

Verify these packages are installed

sudo apt-get install make 
sudo apt-get install gcc
sudo apt-get install openssl

Install package

sudo apt-get install libssl-dev

Install and compile Apache APR

cd /opt/tomcat/bin
sudo wget http://apache.mirror.anlx.net//apr/apr-1.5.2.tar.gz
sudo tar -xzvf apr-1.5.2.tar.gz
cd apr-1.5.2
sudo ./configure
sudo make
sudo make install

verify installation

cd /usr/local/apr/lib/
ls 

you should see the compiled file as

libapr-1.la

Download and install Tomcat Native source package

cd /opt/tomcat/bin
sudo wget https://archive.apache.org/dist/tomcat/tomcat-connectors/native/1.2.10/source/tomcat-native-1.2.10-src.tar.gz
sudo tar -xzvf tomcat-native-1.2.10-src.tar.gz
cd tomcat-native-1.2.10-src/native

verify JAVA_HOME

sudo pico ~/.bashrc
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
source ~/.bashrc
sudo ./configure --with-apr=/usr/local/apr --with-java-home=$JAVA_HOME
sudo make
sudo make install

Edit the /opt/tomcat/bin/setenv.sh file with following line:

sudo pico /opt/tomcat/bin/setenv.sh
export LD_LIBRARY_PATH='$LD_LIBRARY_PATH:/usr/local/apr/lib'

restart tomcat

sudo service tomcat restart

Solution 6 - Eclipse

on debian 8 I fix it with installing libapr1-dev:

apt-get install libtcnative-1 libapr1-dev

Solution 7 - Eclipse

On Mac OS X:

$ brew install tomcat-native
==> tomcat-native
In order for tomcat's APR lifecycle listener to find this library, you'll
need to add it to java.library.path. This can be done by adding this line
to $CATALINA_HOME/bin/setenv.sh

  CATALINA_OPTS="$CATALINA_OPTS -Djava.library.path=/usr/local/opt/tomcat-native/lib"

If $CATALINA_HOME/bin/setenv.sh doesn't exist, create it and make it executable.

Then add it to the eclipse's tomcat arguments (double-click Server > Open Launch Configuration > Arguments tab > VM arguments)

-Djava.library.path=/usr/local/opt/tomcat-native/lib

Solution 8 - Eclipse

Had this problem as well. If you do have the libraries, but still have this error, it may be a configuration error. Your server.xml may be missing the following line:

 <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />

(Alternatively, it may be commented out). This <Listener>, like other listeners is a child of the top-level <Server>.

Without the <Listener> line, there's no attempt to load the APR library, so LD_LIBRARY_PATH and -Djava.library.path= settings are ignored.

Solution 9 - Eclipse

I had this issue upgrading from Java 8 to 11. After adding this dependency, my app launched without issue:

<dependency>
    <groupId>org.javassist</groupId>
    <artifactId>javassist</artifactId>
    <version>3.25.0-GA</version>
</dependency>

Solution 10 - Eclipse

I had the same problem when tomсat could not find the class. Try to view other log files. Sometimes No class def found error appears in different log files:

  • tomcat8-stdout
  • tomcat8-stderr
  • localhost

Solution 11 - Eclipse

If you don't have Tomcat Native library install it with: > sudo apt-get install libtcnative-1

and if it's still there an old version upgrade it with: > sudo apt-get upgrade libtcnative-1

Solution 12 - Eclipse

My problem was in add some library from tomcat to eclipse class path i just going to eclipse click right to project and going to debug configuration -> classpath -> Add External JARs add all jars files from apache-tomcat-7.0.35\bin this was my problem and it's worked for me .
enter image description here

Solution 13 - Eclipse

For future readers: I had faced this issue myself when trying to run a Spring Boot application in Spring STS. This issue didn't resurface initially. I was able to work on my project without any issues for quite some time until one fine day I started getting this particular error.

From what I am able to recall I had not made any configuration changes to my project and neither changed the Java/Tomcat version being used.

None of the discussions/suggestions regarding installing the tomcat native library made any sense to me since the project was already working fine before.

SOLUTION that worked for me:

So lastly I though of trying to delete and reimport my project.

I deleted my project from Spring STS, restarted the Spring STS and then reimported the project. It worked like a charm and never faced the issue ever since.

You may also try deleting any IDE generated files/folders(if there are any) in your project, before restarting the IDE and reimporting the project.

I still happen to work on this project from time to time and haven't faced the issue as of now. My current development IDE is IntelliJ.

I'm not sure if the error was IDE specific.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionfresh_devView Question on Stackoverflow
Solution 1 - EclipseGeertPtView Answer on Stackoverflow
Solution 2 - EclipseMatthew FarwellView Answer on Stackoverflow
Solution 3 - Eclipseuser911734View Answer on Stackoverflow
Solution 4 - EclipseAmadu BahView Answer on Stackoverflow
Solution 5 - EclipseRussell RottachView Answer on Stackoverflow
Solution 6 - EclipseHasan RamezaniView Answer on Stackoverflow
Solution 7 - EclipseRyan WibawaView Answer on Stackoverflow
Solution 8 - EclipseMSaltersView Answer on Stackoverflow
Solution 9 - EclipseStephen PaulView Answer on Stackoverflow
Solution 10 - EclipseKossView Answer on Stackoverflow
Solution 11 - EclipseDejanView Answer on Stackoverflow
Solution 12 - EclipseAbd AbughazalehView Answer on Stackoverflow
Solution 13 - EclipseAsif Kamran MalickView Answer on Stackoverflow