APR based Apache Tomcat Native library was not found on the java.library.path?
When trying to run my app with eclipse/linux on tomcat I got the following info message:
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr开发者_开发技巧/lib/jvm/java-6-sun-1.6.0.20/jre/lib/amd64/server:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/amd64:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/../lib/amd64:/usr/lib64/xulrunner-addons:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
How do I resolve this issue?
My case: Seeing the same INFO message.
Centos 6.2 x86_64 Tomcat 6.0.24
This fixed the problem for me:
yum install tomcat-native
boom!
For Ubntu Users
1. Install compilers
#sudo apt-get install make
#sudo apt-get install gcc
2. Install openssl and development libraries
#sudo apt-get install openssl
#sudo apt-get install libssl-dev
3. Install the APR package (Downloaded from http://apr.apache.org/)
#tar -xzf apr-1.4.6.tar.gz
#cd apr-1.4.6/
#sudo ./configure
#sudo make
#sudo make install
You should see the compiled file as
/usr/local/apr/lib/libapr-1.a
4. Download, compile and install Tomcat Native sourse package
tomcat-native-1.1.27-src.tar.gz
Extract the archive into some folder
#tar -xzf tomcat-native-1.1.27-src.tar.gz
#cd tomcat-native-1.1.27-src/jni/native
#JAVA_HOME=/usr/lib/jvm/jdk1.7.0_21/
#sudo ./configure --with-apr=/usr/local/apr --with-java-home=$JAVA_HOME
#sudo make
#sudo make install
Now I have compiled Tomcat Native library in /usr/local/apr/libtcnative-1.so.0.1.27 and symbolic link file /usr/local/apr/@libtcnative-1.so pointed to the library
5. Create or edit the $CATALINA_HOME/bin/setenv.sh file with following lines :
export LD_LIBRARY_PATH='$LD_LIBRARY_PATH:/usr/local/apr/lib'
6. Restart tomcat and see the desired result:
Download the appropriate APR based tomcat native library for your operating system so that Apache tomcat server can take some advantage of the feature of your OS which is not included by default in tomcat. For windows it will be a .dll
file.
I too got the warning while starting the server and you don't have to worry about this if you are testing or developing. This is meant to be on production purposes. After putting the tcnative-1.dll file inside the bin folder of Apache Tomcat 7 following are the output in the stderr file,
Apr 07, 2015 1:14:12 PM org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded APR based Apache Tomcat Native library 1.1.33 using APR version 1.5.1.
Apr 07, 2015 1:14:12 PM org.apache.catalina.core.AprLifecycleListener init
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
Apr 07, 2015 1:14:14 PM org.apache.catalina.core.AprLifecycleListener initializeSSL
INFO: OpenSSL successfully initialized (OpenSSL 1.0.1m 19 Mar 2015)
Apr 07, 2015 1:14:14 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-apr-127.0.0.1"]
I resolve this (On Eclipse IDE) by delete my old server and create the same again. This error is because you don't proper terminate Tomcat server and close Eclipse.
精彩评论