Tomcat 9 SSL/TLS - 无法初始化组件错误

我有 Tomcat 9.0.12 和 Java JDK/JRE 1.8.0_191。我正在尝试配置 SSL/TLS。我已经像这样更改了我的 server.xml 文件:


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

               connectionTimeout="20000"

               redirectPort="443" />


<Connector port="443" protocol="org.apache.coyote.http11.Http11Protocol" SSLEnabled="true"

               maxThreads="150" scheme="https" secure="true"

               clientAuth="false" sslProtocol="TLS" 

               keystoreFile="C:\my_certificate.pfx"

               keystorePass="my_password" keystoreType="PKCS12" />

我的证书文件是 *.pfx 格式。我通过命令行使用 startup.bat 命令运行 tomcat 服务器。但是我收到了这样的错误(在我的 catalina.log 中):


...

05-Nov-2018 16:33:57.080 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]

05-Nov-2018 16:33:57.190 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read

05-Nov-2018 16:33:57.205 SEVERE [main] org.apache.catalina.util.LifecycleBase.handleSubClassException Failed to initialize component [Connector[org.apache.coyote.http11.Http11Protocol-443]]

 org.apache.catalina.LifecycleException: Protocol handler instantiation failed

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

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

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

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

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

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

当我尝试连接http://localhost:443 时,我得到了 ERR_CONNECTION_REFUSED,我在下面添加了它。

ERR_CONNECTION_REFUSED:

http://img.mukewang.com/61cda3390001167304720430.jpg


富国沪深
浏览 577回答 2
2回答

HUH函数

在Tomcat 9.0.x中,通过更新server.xml文件的Connector元素中的协议属性值来消除以下异常。例外:27-Mar-2020 08:06:45.726 SEVERE [main] org.apache.catalina.util.LifecycleBase.handleSubClassException Failed to initialize component [Connector[org.apache.coyote.http11.Http11Protocol-auto-null]]org.apache.catalina.LifecycleException: Protocol handler instantiation failed27-Mar-2020 08:06:44.929 SEVERE [main] org.apache.catalina.connector.Connector.<init> Protocol handler instantiation failedjava.lang.ClassNotFoundException: org.apache.coyote.http11.Http11Protocol异常语法:<Connector port="9443"&nbsp;&nbsp; &nbsp; protocol="org.apache.coyote.http11.Http11Protocol"&nbsp; &nbsp; maxThreads="200"&nbsp;&nbsp; &nbsp; SSLEnabled="true"&nbsp;&nbsp; &nbsp; scheme="https"&nbsp;&nbsp; &nbsp; secure="true"&nbsp; &nbsp; clientAuth="want"&nbsp;&nbsp; &nbsp; sslProtocol="TLS"&nbsp;&nbsp; &nbsp; connectionTimeout="20000"&nbsp;&nbsp; &nbsp; keystoreFile="D:\\MYAPP\\DINESH_LOMTE\\dlomte_keystore.jks"&nbsp;&nbsp; &nbsp; keystorePass="cardinal"&nbsp;&nbsp; &nbsp; keystoreType="JKS"&nbsp; &nbsp; truststoreFile="D:\\MYAPP\\DINESH_LOMTE\\dlomte_truststore.jks"&nbsp;&nbsp; &nbsp; truststorePass="cardinal"&nbsp;&nbsp; &nbsp; truststoreType="JKS"/>在上面的连接器元素语法中更新协议属性值从protocol="org.apache.coyote.http11.Http11Protocol"到protocol="org.apache.coyote.http11.Http11NioProtocol"注意:为了使用显式协议而不是依赖自动切换机制,可以使用以下值之一,根据您的要求选择org.apache.coyote.http11.Http11NioProtocol - non blocking Java NIO connectororg.apache.coyote.http11.Http11Nio2Protocol - non blocking Java NIO2 connectororg.apache.coyote.http11.Http11AprProtocol - the APR/native connector.

繁星淼淼

我遇到过同样的问题。它开始初始化一个非 io-blocking 连接器05-Nov-2018&nbsp;16:33:57.080&nbsp;INFO&nbsp;[main]&nbsp;org.apache.coyote.AbstractProtocol.init&nbsp;Initializing&nbsp;ProtocolHandler&nbsp;["http-nio-8080"]但是您的配置建议使用 io 阻塞连接器Http11Protocol所以也许你会尝试使用其他连接器。在我的情况下,更改Http11Protocol为Http11NioProtocol有助于修复此错误。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java