很多时候我们刚刚下载的tomcat在启动的时候会看到类似下面的冗杂信息:
信息: The Apache Tomcat Native library which allows optimal performance in produ
ction environments was not found on the java.library.path: D:jdk1. 5 .0_06/bin;.;
C:WINDOWSsystem32;C:WINDOWS;D:jdk1. 5 .0_06/bin;D:oracleora92/bin;C:Program
FilesOraclejre 1.3 . 1/b in;C:Program FilesOraclejre 1.1 . 8/b in;C:WINDOWSsys
tem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:Program FilesMicrosoft SQL Server
80 ToolsBINN
发生这种情况是因为Tomcat建议使用apache的apr
解决办法:
到 http://tomcat.heanet.ie/native/ 下载编译好的 tcnative-1.dll 文件,目前最新为1.1.10,拷贝至jdk/bin下或Tomcat的bin目录下,重新启动Tomcat就可以成功加载APR了.
信息如下:
信息: Initializing Coyote HTTP / 1.1 on http - 8080
2007 - 12 - 15 22 : 48 : 30 org.apache.coyote.ajp.AjpAprProtocol init
信息: Initializing Coyote AJP / 1.3 on ajp - 8009
2007 - 12 - 15 22 : 48 : 30 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 1063 ms
2007 - 12 - 15 22 : 48 : 30 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2007 - 12 - 15 22 : 48 : 30 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat / 5.5 . 20
2007 - 12 - 15 22 : 48 : 30 org.apache.catalina.core.StandardHost start
.......................
官方信息可查阅:
地址: http://tomcat.apache.org/tomcat-5.5-doc/apr.html
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).
These features allows making Tomcat a general purpose webserver, will enable much better integration with other native web technologies, and overall make Java much more viable as a full fledged webserver platform rather than simply a backend focused technology.
似乎是Tomcat 可以用 Apache Portable Runtime 来提供更强性能,提升Web静态页面的处理能力,
不再需要专门的Web Server来处理静态页面了。
但是APR的支持需要安装三个本地组件
APR support requires three main native components to be installed:
1、APR library
2、JNI wrappers for APR used by Tomcat (libtcnative)
3、OpenSSL libraries
解决:Windows下的安装配置与使用
1、先去 http://tomcat.heanet.ie/native/ 下载编译好的 tcnative-1.dll 文件,也可以下载tomcat-native.zip自己进行编译
2、修改一下 catalina.bat,加上
set CATALINA_OPTS="-Djava.library.path=../../APR/lib"
因为我把这个DLL放在与Tomcat目录同级的APR/lib目录下,所以采用了相对路径。或者把dll加到你的系统变量PATH里之类的,最简单的方法应当就是把tcnative-1.dll文件放在Tomcat的bin目录下
相关的性能测试结果可以参见:
http://www.javaworld.com.tw/jute/post/view?bid=9&id=139958&sty=3&age=0