【问题标题】:Tomcat: Failed to start connector [Connector[HTTP/1.1-auto-1]]Tomcat:无法启动连接器 [连接器 [HTTP/1.1-auto-1]]
【发布时间】:2022-01-03 18:08:10
【问题描述】:

您好,我正在尝试将我的应用程序部署在远程 tomcat 服务器 (8.5.30) 上。为了让我的应用程序运行,我需要在 /conf/server.xml 上添加这些行

<Connector SSLEnabled="true" 
                clientAuth="false" keystoreFile="blc-example.keystore" keystorePass="xx" 
                keyPass="xx" maxThreads="150"
                scheme="https" secure="true" sslProtocol="TLS" />

这在我的本地机器上运行良好。但是由于某种原因在远程服务器上我在启动时收到此错误

02-Jan-2019 16:19:37.783 SEVERE [main] org.apache.catalina.core.StandardService.startInternal Failed to start connector [Connector[HTTP/1.1-auto-1]]
 org.apache.catalina.LifecycleException: Failed to start component [Connector[HTTP/1.1-auto-1]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:440)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:681)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:353)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:493)
Caused by: org.apache.catalina.LifecycleException: The connector cannot start since the specified port value of [-1] is invalid
    at org.apache.catalina.connector.Connector.startInternal(Connector.java:1011)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 11 more

我很确定 tomcat 可以看到 keystoreFile,否则我会收到文件未找到错误。

所有设置都与我的本地计算机相同,因此我非常困惑为什么会发生这种情况。有什么建议吗?

【问题讨论】:

    标签: tomcat8


    【解决方案1】:

    在您的连接器上设置一个端口,它确实在错误中说它默认为一个不存在的无效端口:

    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true" 
               clientAuth="false" keystoreFile="blc-example.keystore" keystorePass="xx" 
               keyPass="xx" maxThreads="150"
               scheme="https" secure="true" sslProtocol="TLS" />
    

    【讨论】:

      【解决方案2】:

      这是因为您的连接器配置中缺少端口。

      在Connector中不设置端口时,tomcat会从系统可用的空闲端口中随机选择一个端口。

      在您的情况下,您的远程服务器上可能存在限制(出于安全原因),以便 tomcat 使用随机可用端口,这就是它自动默认为 -1 的原因,这是一个无效端口。它可以在本地工作,因为本地机器上的随机端口没有任何限制。

      因此,在您的配置中,您应该明确设置服务器平台允许的端口。

      【讨论】:

      • elyor 和@Mike K。感谢你们的回答和解释,它解决了我的问题
      猜你喜欢
      • 2019-09-22
      • 2019-07-27
      • 2018-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-17
      • 1970-01-01
      • 2017-03-31
      相关资源
      最近更新 更多