2

我目前正在使用 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>

这就是started 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].
4

1 回答 1

2

发生此错误是因为并非所有 OpenLiberty 功能都相互兼容,如果您启用冲突功能,您会收到指示哪些功能冲突的错误。它应该可以通过在 server.xml 中启用附加功能来解决,以帮助运行时消除应启用哪些功能的歧义。

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

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

要分解您启用的功能的依赖关系,它看起来像这样:

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