在配置一套新的测试环境,配置完成后,发现tomcat一直无法正常访问,同时tomcat服务是正常的,这说明出来了网络上。

     以下是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/local/java/jdk1.6.0_45/jre/lib/amd64/server:/usr/local/java/jdk1.6.0_45/jre/lib/amd64:/usr/local/java/jdk1.6.0_45/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib

Oct 31, 2017 3:03:07 PM org.apache.coyote.AbstractProtocol init

INFO: Initializing ProtocolHandler ["http-bio-0:0:0:0:0:0:0:0-9002"]

Oct 31, 2017 3:03:07 PM org.apache.coyote.AbstractProtocol init

SEVERE: Failed to initialize end point associated with ProtocolHandler ["http-bio-0:0:0:0:0:0:0:0-9002"]

java.net.SocketException: Protocol family unavailable

at java.net.PlainSocketImpl.socketBind(Native Method)

at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:383)

at java.net.ServerSocket.bind(ServerSocket.java:328)

at java.net.ServerSocket.(ServerSocket.java:194)

at org.apache.tomcat.util.net.DefaultServerSocketFactory.createSocket(DefaultServerSocketFactory.java:55)

at org.apache.tomcat.util.net.JIoEndpoint.bind(JIoEndpoint.java:403)

at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:649)

at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:434)

at org.apache.coyote.http11.AbstractHttp11JsseProtocol.init(AbstractHttp11JsseProtocol.java:119)

at org.apache.catalina.connector.Connector.initInternal(Connector.java:978)

at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)

at org.apache.catalina.core.StandardService.initInternal(StandardService.java:559)

at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)

at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:821)

at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)

at org.apache.catalina.startup.Catalina.load(Catalina.java:638)

at org.apache.catalina.startup.Catalina.load(Catalina.java:663)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)




通过查询各种资料没有结果,最后发现tomcat server.xml中有这个一个配置:

  

<Connector port="9001" protocol="HTTP/1.1"

           URIEncoding="UTF-8" 

           minSpareThreads="100" 

           maxSpareThreads="1000" 

           enableLookups="false" 

           disableUploadTimeout="true" 

           connectionTimeout="20000" 

           acceptCount="1000" 

           maxThreads="1000" 

           minProcessors="100" 

           maxProcessors="1000" 

           useURIValidationHack="false" 

           compression="on" 

           compressionMinSize="2048"

           address="0:0:0:0:0:0:0:0" 

           compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain" 

           redirectPort="9443" />



  以i上标红的这一行,问题就是这里了,去掉即正常了!


本文版权归作者,欢迎转载,但未经作者同意必须在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。