部署Tomcat的时候出现了如下错误,
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/jdk1.6.0_30/jre/lib/amd64/server:/usr/java/jdk1.6.0_30/jre/lib/amd64:/usr/java/jdk1.6.0_30/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
其实这个问题以前解决过,但是没有记录,所以今天解决了以后决定把它记下来。
原因很简单,就是Tomcat在Server.xml中默认有配置加载ARP library,但是没找到相关文件。
配置文件是这样写的,
<!--APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
配置中讲的/docs/apr.html网上的版本是
http://tomcat.apache.org/tomcat-6.0-doc/apr.html
意思是装上libtcnative就好了,这个包在Tomcat发行版中就包含了,在bin/tomcat-native.tar.gz.
安装前先确保你的机器已安装,openssl,JDK,apr,apr-devel,然后解压此文件,使用经典的./configure && make && make install,如果报找不到apr可以在configure时增加--with-apr=/usr/bin/apr-1-config.
安装完成后,libtcnative.1.so被放在了/usr/local/apr/,但是Tomcat的java.library.path并不包含这个目录,可以使用ln -s /usr/local/apr/lib/libtcnative-1.so /usr/lib64/libtcnative-1.so命令解决。
重启Tomcat,可以在日志中看到,APR模块已经正常加载。
Jul 10, 2012 11:52:49 AM org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded APR based Apache Tomcat Native library 1.1.24.
然后,发现日志中有另外的错误
Jul 10, 2012 11:52:49 AM org.apache.coyote.http11.Http11AprProtocol init
SEVERE: Error initializing endpoint
java.lang.Exception: No Certificate file specified or invalid file format
at org.apache.tomcat.jni.SSLContext.setCertificate(Native Method)
at org.apache.tomcat.util.net.AprEndpoint.init(AprEndpoint.java:733)
at org.apache.coyote.http11.Http11AprProtocol.init(Http11AprProtocol.java:107)
at org.apache.catalina.connector.Connector.initialize(Connector.java:1049)
at org.apache.catalina.core.StandardService.initialize(StandardService.java:703)
at org.apache.catalina.core.StandardServer.initialize(StandardServer.java:838)
at org.apache.catalina.startup.Catalina.load(Catalina.java:538)
at org.apache.catalina.startup.Catalina.load(Catalina.java:562)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:261)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Jul 10, 2012 11:52:49 AM org.apache.catalina.core.StandardService initialize
SEVERE: Failed to initialize connector [Connector[HTTP/1.1-8443]]
LifecycleException: Protocol handler initialization failed: java.lang.Exception: No Certificate file specified or invalid file format
at org.apache.catalina.connector.Connector.initialize(Connector.java:1051)
at org.apache.catalina.core.StandardService.initialize(StandardService.java:703)
at org.apache.catalina.core.StandardServer.initialize(StandardServer.java:838)
at org.apache.catalina.startup.Catalina.load(Catalina.java:538)
at org.apache.catalina.startup.Catalina.load(Catalina.java:562)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:261)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Google得知需要在HTTPS的配置中
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="你的.keystore文件" />
将protocol中的HTTP/1.1改为org.apache.coyote.http11.Http11Protocol就可以解决,不知道为啥。
原帖地址:http://blog.sina.com.cn/s/blog_45c6cec00101izyi.html