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

匿名 (未验证) 提交于 2019-12-03 09:02:45

问题:

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?

回答1:

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 


回答2:

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).



回答3:

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.



回答4:

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:



回答5:

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

apt-get install libtcnative-1 libapr1-dev 


回答6:

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



回答7:

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:

 

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

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



回答8:

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


回答9:

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



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!