open-liberty - 包含 mpHealth 功能会破坏 Open Liberty 中的独立应用程序

标签 open-liberty microprofile

我目前正在使用 Open Liberty 18.0.0.4 及其 Microprofile 支持。当我尝试构建一个包含 mpHealth-1.0 功能的独立可运行 Jar 时,启动失败并显示

[ERROR   ] CWWKF0033E: The singleton features com.ibm.websphere.appserver.javax.servlet-3.1 and com.ibm.websphere.appserver.javax.servlet-4.0 cannot be loaded at the same time.  The configured features mpHealth-1.0 and jaxrs-2.1 include one or more features that cause the conflict. Your configuration is not supported; update server.xml to remove incompatible features.
[ERROR   ] CWWKF0033E: The singleton features com.ibm.websphere.appserver.javax.annotation-1.2 and com.ibm.websphere.appserver.javax.annotation-1.3 cannot be loaded at the same time.  The configured features mpHealth-1.0 and jaxrs-2.1 include one or more features that cause the conflict. Your configuration is not supported; update server.xml to remove incompatible features.
[ERROR   ] CWWKF0033E: The singleton features com.ibm.websphere.appserver.javaeeCompatible-8.0 and com.ibm.websphere.appserver.javaeeCompatible-7.0 cannot be loaded at the same time.  The configured features jsonb-1.0 and mpHealth-1.0 include one or more features that cause the conflict. Your configuration is not supported; update server.xml to remove incompatible features.
[ERROR   ] CWWKF0033E: The singleton features com.ibm.websphere.appserver.javax.cdi-2.0 and com.ibm.websphere.appserver.javax.cdi-1.2 cannot be loaded at the same time.  The configured features jsonb-1.0 and mpHealth-1.0 include one or more features that cause the conflict. Your configuration is not supported; update server.xml to remove incompatible features.

我正在使用 jaxrs-2.1 和 jsonb-1.0,一切正常。一旦我添加 mpHealth-1.0 功能,我就会收到上述错误。这是 server.xml 的相关片段:

    <featureManager>
        <feature>jaxrs-2.1</feature>
        <feature>jsonb-1.0</feature>
        <feature>mpHealth-1.0</feature>
    </featureManager>

这就是启动的 Jar 在结束时所说的内容(但没有服务可用):

[AUDIT   ] CWWKF0012I: The server installed the following features: [jsonb-1.0, servlet-4.0, jndi-1.0, mpHealth-1.0, json-1.0, cdi-1.2, jsonp-1.1, jaxrsClient-2.1, jaxrs-2.1].

最佳答案

出现此错误的原因是并非所有 OpenLiberty 功能都相互兼容,如果您启用冲突的功能,则会收到一条错误消息,指示哪些功能发生冲突。应该可以通过在 server.xml 中启用其他功能来解决该问题,以帮助运行时消除应启用哪些功能的歧义。

功能冲突的两个主要原因是:

  1. 尝试启用同一功能的两个版本(例如 foo-1.0foo-2.0)
  2. 启用了 Java EE 7 和 Java EE 8 功能的混合(例如 EE 7 中的 cdi-1.2 和 EE 8 中的 jaxrs-2.1)

要分解已启用功能的功能依赖性,它看起来像这样:

- jsonb-1.0 -> jsonp-1.1
- jaxrs-2.1 -> cdi-2.0
            -> servlet-4.0
- mpHealth-1.0 -> cdi-1.2 (tolerates cdi-2.0)

您看到这些错误的原因是 OpenLiberty 功能管理器没有足够的证据来知道它可以故障转移到 mpHealth-1.0 -> cdi-2.0 依赖项。

要解决此问题,您有两种选择:

  1. 在 server.xml 中启用 cdi-2.0 功能。这应该有助于消除功能管理器的歧义,以便它可以故障转移到 mpHealth-1.0 -> cdi-2.0 依赖项。
  2. 不要启用个别功能,而是启用 microProfile-2.0 便利功能。在这里,您不必担心功能冲突,但它会在运行时加载更多功能(例如 MP Metrics、MP Config、MP Fault Tolerance 等),这会产生一些额外的启动时间和内存占用成本。<

关于open-liberty - 包含 mpHealth 功能会破坏 Open Liberty 中的独立应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54349181/

相关文章:

java - Quarkus & Microprofile : Is there a better way to use a property from application. 属性进入@ClientHeaderParam?

java - 从 websphere-liberty 16 迁移到版本 17 后出现 SSLHandshakeException

java-8 - 对象消息上的 JMS 消息选择器

postgresql - 如何将 Postgres 驱动程序添加到 Open Liberty?

jax-rs - 在 OpenLiberty jax-rs 上将 POST 请求的默认编码设置为 utf-8

java - Microprofile 在构建时生成 Open-Api 文件

Maven 构建未正确安装功能

java - Open Liberty 下 mpRestClient 证书身份验证握手失败

java - Liberty 空指针异常