【问题标题】:Unable to start jetty server after upgrade to 11.0.6 from 9.4.41.v20210516从 9.4.41.v20210516 升级到 11.0.6 后无法启动码头服务器
【发布时间】:2021-09-09 09:52:37
【问题描述】:

我正在使用码头服务器版本 9.4.41.v20210516 运行我的应用程序,它运行良好。 我最近将码头版本升级到 11.0.6。以下是我的 jetty.xml 文件配置

<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">

<Configure id="Server" class="org.eclipse.jetty.server.Server">

    <Call name="addBean">
        <Arg>
            <New class="org.eclipse.jetty.util.thread.ScheduledExecutorScheduler"/>
        </Arg>
    </Call>

    <New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
        <Set name="sendServerVersion"><Property name="jetty.send.server.version" default="false" /></Set>
        <Set name="sendDateHeader"><Property name="jetty.send.date.header" default="false" /></Set>
    </New>

    <New id="sslContextFactory" class="org.eclipse.jetty.util.ssl.SslContextFactory">
        <Set name="KeyStorePath"><SystemProperty name="mcruncher.app.dataDir" default="." />\<Property name="jetty.keystore" default="temp\keystore.jks"/></Set>
        <Set name="KeyStorePassword">
            <Property name="jetty.keystore.password" default=""/>
        </Set>
        <Set name="EndpointIdentificationAlgorithm"></Set>

        <Set name="IncludeProtocols">
            <Array type="String">
                <Item>TLSv1.2</Item>
            </Array>
        </Set>

        <Set name="IncludeCipherSuites">
            <Array type="String">
                <Item>TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384</Item>
                <Item>TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384</Item>
            </Array>
        </Set>

        <New id="tlsHttpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
            <Arg><Ref refid="httpConfig"/></Arg>
            <Call name="addCustomizer">
                <Arg><New class="org.eclipse.jetty.server.SecureRequestCustomizer"/></Arg>
            </Call>
        </New>
    </New>

    <Call id="sslConnector" name="addConnector">
        <Arg>
            <New class="org.eclipse.jetty.server.ServerConnector">
                <Arg name="server"><Ref refid="Server" /></Arg>
                <Arg name="factories">
                    <Array type="org.eclipse.jetty.server.ConnectionFactory">
                        <Item>
                            <New class="org.eclipse.jetty.server.SslConnectionFactory">
                                <Arg name="next">http/1.1</Arg>
                                <Arg name="sslContextFactory"><Ref refid="sslContextFactory"/></Arg>
                            </New>
                        </Item>
                        <Item>
                            <New class="org.eclipse.jetty.server.HttpConnectionFactory">
                                <Arg name="config"><Ref refid="tlsHttpConfig"/></Arg>
                            </New>
                        </Item>
                    </Array>
                </Arg>
                <Set name="port"><Property name="jetty.port" default="9090" /></Set>
                <Set name="idleTimeout"><Property name="jetty.idleTimeout" default="30000"/></Set>
                <Set name="soLingerTime"><Property name="jetty.soLingerTime" default="-1"/></Set>
            </New>
        </Arg>
    </Call>

</Configure> 

升级后版本jetty server没有启动,出现如下异常

            <Property name="jetty.keystore.password" default=""/>
        </Set><Set name="EndpointIdentificationAlgorithm"/><Set name="IncludeProtocols">
            <Array type="String"><Item>TLSv1.2</Item></Array>
        </Set><Set name="IncludeCipherSuites">
            <Array type="String"><Item>TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384</Item><Item>TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384</Item></Array>
        </Set><New id="tlsHttpConfig" class="org.eclipse.jetty.server.HttpConfiguration"><Arg><Ref refid="httpConfig"/></Arg><Call name="addCustomizer"><Arg><New class="org.eclipse.jetty.server.SecureRequestCustomizer"/></Arg></Call></New></New> on Server@30506c0d{STOPPED}[11.0.6,sto=0]
    at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.newObj(XmlConfiguration.java:1001)
    at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:470)
    at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:380)
    at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:303) 

谁能帮我解决这个问题?

【问题讨论】:

  • 你为什么要编辑jetty.xml?你在使用jetty-home 发行版吗?还是做一些完全定制的事情?
  • 嗨@Joakim Erdfelt,我没有使用jetty-home 分发。它完全是定制的。我现在没有编辑 jetty.xml 文件。这是我到目前为止在我的应用程序中的文件。我刚刚将版本从 9.x 升级到 11.x。升级后我得到了这个异常。

标签: jetty


【解决方案1】:

jetty 用于启动自身的 XML 发生了许多变化。

与您一起查看在jetty-home tarball 自己的 XML 文件中发现的其他更改可能是个好主意。

我注意到的一件事是,您仍在 XML 中使用旧的通用 SslContextFactory(强烈建议不要这样做,因为它不区分服务器模式和客户端模式)。

这就是你正在使用的......

<New id="sslContextFactory" class="org.eclipse.jetty.util.ssl.SslContextFactory">

在 Jetty 9.x 中使用该类将导致警告甚至错误(取决于您的密钥库中的内容)

在 Jetty 9.x 中,您应该使用服务器或客户端特定版本。

示例:从 9.4.43 ${jetty.home}/etc/jetty-ssl-context.xml

<Configure id="sslContextFactory"
    class="org.eclipse.jetty.util.ssl.SslContextFactory$Server">

在 Jetty 9.x 中使用 ClientServer 特定实现是可选的,以允许代码迁移。

在 Jetty 10.x 中,泛型类 (SslContextFactory) 现在是抽象的,本来应该是这样的。

您现在必须使用特定的实现。

示例:来自 11.0.6 ${jetty.home}/etc/jetty-ssl-context.xml

<New id="sslContextFactory"
    class="org.eclipse.jetty.util.ssl.SslContextFactory$Server">

另请注意,Jetty 9.4.x 中的默认密钥库格式/类型是 JKS,但从 Jetty 10.0.x 开始,现在是 PKCS12

【讨论】:

  • 嗨@Joakim,感谢您的回复。使用SslContextFactory$Server后可以启动服务器。谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-12-17
  • 2018-10-29
  • 1970-01-01
  • 1970-01-01
  • 2022-12-07
相关资源
最近更新 更多