解决Linux下Tomcat由于Tomcat Native问题启动报错

来源:互联网 发布:linux自启动脚本配置 编辑:程序博客网 时间:2024/05/16 11:02
omact服务启动报错日志如下信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: $JAVA_HOME/jre/lib/amd64/server:$JAVA_HOME/jre/lib/amd64:$JAVA_HOME/jre/../lib/amd64:/usr/java/packages/lib/amd64:/lib:/usr/lib
是由于缺少apr的支持: 
Tomcat Native 是利用 APR 来提升Tomcat性能的本地API
Tomcat Native 这个项目可以让 Tomcat 使用 Apache 的 apr 包来处理包括文件和网络IO操作,以提升性能。
以下是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).

解决方案:

安装apr-devel

#yum install apr-devel

进入tomcat安装目录

#cd $CATALINA_HOME/bin

解压文件到当前目录

#tar zxf tomcat-native.tar.gz

进入native源码目录
#cd $CATALINA_HOME/bin/tomcat-native-1.1.27-src/jni/native

配置编译信息
#./configure --with-apr=/usr/bin/apr-1-config --with-java-home=$JAVA_HOME --prefix=$CATALINA_HOME

编译
make && make install
安装成功如下提示:
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/apr/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.


添加配置:

tomcat安装目录bin下创建setenv.sh文件:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CATALINA_HOME/lib
    export LD_LIBRARY_PATH

tomcat启动后查看日志 apr已加载上
2013-6-8 14:31:05 org.apache.catalina.core.AprLifecycleListener init
信息: Loaded APR based Apache Tomcat Native library 1.1.23 using APR version 1.3.9.
2013-6-8 14:31:05 org.apache.catalina.core.AprLifecycleListener init
信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].

如果还是报错则进入到.libs/libs目录(这里32位和64位有区别)

ls -al:

libtcnative-1.a

libtcnative-1.la -> ../libtcnative-1.la

libtcnative-1.lai

libtcnative-1.so -> libtcnative-1.so.0.1.27

libtcnative-1.so.0 -> libtcnative-1.so.0.1.27

libtcnative-1.so.0.1.27

里面有几个链接文件,把

libtcnative-1.a

libtcnative-1.lai

libtcnative-1.so.0.1.27

和libtcnative-1.la链接指向的文件(上一级目录的libtcnative-1.la)拷贝到$JAVA_HOME/jre/lib/amd64(i386-32位系统)/server下即可。




如果windows下报错是拷贝几个dll文件至windows/system32下,apache官网有。

原创粉丝点击