将 war 部署到 payara 会引发严重错误:无法为 Mojarra 获取 CDI 1.1 实用程序

问题描述

由于这是在相当大的代码库中发生的,而且我什至不知道如何开始隔离问题,因此我无法给出一个小的重现示例。 也许您可以帮助我进一步调试问题,并逐步提供具有相同症状的小场景。

在payara micro 5.2021.2中部署.war文件出现如下错误

[2021-04-26T10:10:09.096+0000] [] [SEVERE] [] [javax.enterprise.resource.webcontainer.jsf.application.view] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1619431809096] [levelValue: 1000] Unable to obtain CDI 1.1 utilities for Mojarra

[2021-04-26T10:10:09.109+0000] [] [SEVERE] [] [javax.enterprise.resource.webcontainer.jsf.flow] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1619431809109] [levelValue: 1000] Unable to obtain CDI 1.1 utilities for Mojarra

[2021-04-26T10:10:09.181+0000] [] [SEVERE] [NCLS-CORE-00026] [javax.enterprise.system.core] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1619431809181] [levelValue: 1000] [[
  Exception during lifecycle processing
org.glassfish.deployment.common.DeploymentException: CDI deployment failure:Error while loading class fish.payara.security.oauth2.OAuth2AuthenticationMechanism$Proxy$_$$_WeldSubclass -- Error while loading class fish.payara.security.oauth2.OAuth2AuthenticationMechanism$Proxy$_$$_WeldSubclass
    at org.jboss.weld.resources.Classtransformer.getBackedAnnotatedType(Classtransformer.java:186)
    at org.jboss.weld.resources.Classtransformer.getBackedAnnotatedType(Classtransformer.java:194)
    at org.jboss.weld.resources.Classtransformer.getEnhancedAnnotatedType(Classtransformer.java:232)
    at org.jboss.weld.injection.producer.SubclassedComponentInstantiator.initEnhancedSubclass(SubclassedComponentInstantiator.java:86)
    at org.jboss.weld.injection.producer.SubclassedComponentInstantiator.<init>(SubclassedComponentInstantiator.java:79)
    at org.jboss.weld.injection.producer.SubclassedComponentInstantiator.forInterceptedDecoratedBean(SubclassedComponentInstantiator.java:63)
    at org.jboss.weld.injection.producer.BeanInjectionTarget.initializeAfterBeandiscovery(BeanInjectionTarget.java:121)
    at org.jboss.weld.injection.producer.InjectionTargetinitializationContext.initialize(InjectionTargetinitializationContext.java:42)
    at org.jboss.weld.injection.producer.InjectionTargetService.initialize(InjectionTargetService.java:63)
    at org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:481)
    at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:86)
    at org.glassfish.weld.WeldDeployer.processApplicationLoaded(WeldDeployer.java:521)
    at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:433)
    at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
    at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:346)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.prepare(ApplicationLifecycle.java:570)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:576)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:556)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:552)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:360)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:551)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:582)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:574)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:360)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:573)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1497)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:120)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1879)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1755)
    at com.sun.enterprise.admin.cli.embeddable.CommandExecutorImpl.executeCommand(CommandExecutorImpl.java:183)
    at com.sun.enterprise.admin.cli.embeddable.CommandExecutorImpl.run(CommandExecutorImpl.java:96)
    at fish.payara.boot.runtime.BootCommand.execute(BootCommand.java:69)
    at fish.payara.boot.runtime.BootCommands.executeCommands(BootCommands.java:136)
    at fish.payara.boot.runtime.BootCommands.executeCommands(BootCommands.java:130)
    at fish.payara.micro.impl.PayaraMicroImpl.bootStrap(PayaraMicroImpl.java:1049)
    at fish.payara.micro.impl.PayaraMicroImpl.create(PayaraMicroImpl.java:226)
    at fish.payara.micro.impl.PayaraMicroImpl.main(PayaraMicroImpl.java:213)
    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 fish.payara.micro.boot.loader.MainMethodRunner.run(MainMethodRunner.java:50)
    at fish.payara.micro.boot.loader.Launcher.launch(Launcher.java:114)
    at fish.payara.micro.boot.loader.Launcher.launch(Launcher.java:73)
    at fish.payara.micro.boot.PayaraMicroLauncher.create(PayaraMicroLauncher.java:88)
    at fish.payara.micro.boot.PayaraMicroLauncher.main(PayaraMicroLauncher.java:72)
    at fish.payara.micro.PayaraMicro.main(PayaraMicro.java:467)
]]

[2021-04-26T10:10:09.182+0000] [] [SEVERE] [] [javax.enterprise.system.core] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1619431809182] [levelValue: 1000] Exception while loading the app

因此未部署该应用。

到目前为止我做了什么:

  • 查看依赖树并确保战争不包含任何会干扰 payara 提供的东西的依赖
  • 尝试在谷歌上搜索 payara 和这些问题的组合。运气不是很好。 JBoss/WildFly 的东西出现了,但我无法真正将它与我的问题联系起来
  • 查看 javax faces 的源代码以查看实际的 Unable to obtain CDI 1.1 utilities for Mojarra 消息在哪里抛出。
  • 试图了解为什么甚至加载了该代码,但我找不到任何连接。

这里是依赖项:

mvn dependency:tree | grep compile
[INFO] +- INTERNAL_LIB:INTERNAL_LIB:jar:1.0.0:compile
[INFO] |  +- org.antlr:antlr4-runtime:jar:4.9.2:compile
[INFO] |  +- commons-beanutils:commons-beanutils:jar:1.9.4:compile
[INFO] |  |  \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] +- com.auth0:auth0:jar:1.29.0:compile
[INFO] |  +- com.squareup.okhttp3:logging-interceptor:jar:4.9.0:compile
[INFO] |  |  \- org.jetbrains.kotlin:kotlin-stdlib-jdk8:jar:1.4.10:compile
[INFO] |  |     \- org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.4.10:compile
[INFO] +- io.jsonwebtoken:jjwt:jar:0.9.1:compile
[INFO] +- com.auth0:jwks-rsa:jar:0.17.1:compile
[INFO] +- redis.clients:jedis:jar:3.5.2:compile
[INFO] |  \- org.apache.commons:commons-pool2:jar:2.6.2:compile
[INFO] +- com.google.guava:guava:jar:30.1.1-jre:compile
[INFO] |  +- com.google.guava:failureaccess:jar:1.0.1:compile
[INFO] |  +- com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:compile
[INFO] |  +- com.google.code.findbugs:jsr305:jar:3.0.2:compile
[INFO] |  +- org.checkerframework:checker-qual:jar:3.8.0:compile
[INFO] |  +- com.google.errorprone:error_prone_annotations:jar:2.5.1:compile
[INFO] |  \- com.google.j2objc:j2objc-annotations:jar:1.3:compile
[INFO] +- joda-time:joda-time:jar:2.10.10:compile
[INFO] +- software.amazon.awssdk:s3:jar:2.16.44:compile
[INFO] |  +- software.amazon.awssdk:aws-xml-protocol:jar:2.16.44:compile
[INFO] |  |  \- software.amazon.awssdk:aws-query-protocol:jar:2.16.44:compile
[INFO] |  +- software.amazon.awssdk:protocol-core:jar:2.16.44:compile
[INFO] |  +- software.amazon.awssdk:arns:jar:2.16.44:compile
[INFO] |  +- software.amazon.awssdk:profiles:jar:2.16.44:compile
[INFO] |  +- software.amazon.awssdk:sdk-core:jar:2.16.44:compile
[INFO] |  |  \- org.reactivestreams:reactive-streams:jar:1.0.2:compile
[INFO] |  +- software.amazon.awssdk:auth:jar:2.16.44:compile
[INFO] |  |  \- software.amazon.eventstream:eventstream:jar:1.0.1:compile
[INFO] |  +- software.amazon.awssdk:http-client-spi:jar:2.16.44:compile
[INFO] |  +- software.amazon.awssdk:regions:jar:2.16.44:compile
[INFO] |  +- software.amazon.awssdk:annotations:jar:2.16.44:compile
[INFO] |  +- software.amazon.awssdk:utils:jar:2.16.44:compile
[INFO] |  +- software.amazon.awssdk:aws-core:jar:2.16.44:compile
[INFO] |  +- software.amazon.awssdk:metrics-spi:jar:2.16.44:compile
[INFO] |     +- io.netty:netty-codec-http:jar:4.1.61.Final:compile
[INFO] |     +- io.netty:netty-codec:jar:4.1.61.Final:compile
[INFO] |     +- io.netty:netty-transport:jar:4.1.61.Final:compile
[INFO] |     |  \- io.netty:netty-resolver:jar:4.1.61.Final:compile
[INFO] |     +- io.netty:netty-common:jar:4.1.61.Final:compile
[INFO] |     +- io.netty:netty-buffer:jar:4.1.61.Final:compile
[INFO] |     +- io.netty:netty-handler:jar:4.1.61.Final:compile
[INFO] |     +- io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.61.Final:compile
[INFO] |     |  \- io.netty:netty-transport-native-unix-common:jar:4.1.61.Final:compile
[INFO] +- com.amazonaws:aws-java-sdk-sqs:jar:1.11.1001:compile
[INFO] |  +- com.amazonaws:aws-java-sdk-core:jar:1.11.1001:compile
[INFO] |  |  \- software.amazon.ion:ion-java:jar:1.0.2:compile
[INFO] |  \- com.amazonaws:jmespath-java:jar:1.11.1001:compile
[INFO] +- com.cloudbees.thirdparty:zendesk-java-client:jar:0.14.1:compile
[INFO] |  +- org.asynchttpclient:async-http-client:jar:2.12.2:compile
[INFO] |  |  +- org.asynchttpclient:async-http-client-netty-utils:jar:2.12.2:compile
[INFO] |  |  +- io.netty:netty-codec-socks:jar:4.1.53.Final:compile
[INFO] |  |  +- io.netty:netty-handler-proxy:jar:4.1.53.Final:compile
[INFO] |  |  +- io.netty:netty-transport-native-kqueue:jar:osx-x86_64:4.1.53.Final:compile
[INFO] |  |  \- com.typesafe.netty:netty-reactive-streams:jar:2.0.4:compile
[INFO] |  \- com.damnhandy:handy-uri-templates:jar:2.1.8:compile
[INFO] +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.12.3:compile
[INFO] |  +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.12.3:compile
[INFO] |  \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.12.3:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.12.3:compile
[INFO] +- com.fasterxml.jackson.datatype:jackson-datatype-joda:jar:2.12.3:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.12.3:compile
[INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.12.3:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.12.0:compile
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.5.13:compile
[INFO] |  +- org.apache.httpcomponents:httpcore:jar:4.4.13:compile
[INFO] |  \- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- com.googlecode.concurrent-trees:concurrent-trees:jar:2.6.1:compile
[INFO] +- com.warrenstrange:googleauth:jar:1.5.0:compile
[INFO] +- commons-codec:commons-codec:jar:1.15:compile
[INFO] +- com.timgroup:java-statsd-client:jar:3.1.0:compile
[INFO] +- org.influxdb:influxdb-java:jar:2.21:compile
[INFO] |  +- com.squareup.retrofit2:retrofit:jar:2.9.0:compile
[INFO] |  +- com.squareup.retrofit2:converter-moshi:jar:2.9.0:compile
[INFO] |  |  \- com.squareup.moshi:moshi:jar:1.8.0:compile
[INFO] |  \- org.msgpack:msgpack-core:jar:0.8.21:compile
[INFO] +- com.opencsv:opencsv:jar:5.4:compile
[INFO] |  +- org.apache.commons:commons-text:jar:1.9:compile
[INFO] |  \- org.apache.commons:commons-collections4:jar:4.4:compile
[INFO] +- nl.big-o:liqp:jar:0.7.9:compile
[INFO] |  \- org.jsoup:jsoup:jar:1.11.3:compile
[INFO] +- net.jodah:failsafe:jar:2.4.0:compile
[INFO] +- com.squareup.okhttp3:okhttp:jar:4.9.1:compile
[INFO] |  +- com.squareup.okio:okio:jar:2.8.0:compile
[INFO] |  |  \- org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.4.0:compile
[INFO] |  \- org.jetbrains.kotlin:kotlin-stdlib:jar:1.4.10:compile
[INFO] |     \- org.jetbrains:annotations:jar:13.0:compile
[INFO] +- commons-io:commons-io:jar:2.8.0:compile
[INFO] +- io.searchBox:jest:jar:2.0.4:compile
[INFO] |  +- io.searchBox:jest-common:jar:2.0.4:compile
[INFO] |  |  \- com.google.code.gson:gson:jar:2.6.2:compile
[INFO] |  +- org.apache.httpcomponents:httpcore-nio:jar:4.4.4:compile
[INFO] |  \- org.apache.httpcomponents:httpasyncclient:jar:4.1.1:compile
[INFO] |  +- org.apache.lucene:lucene-core:jar:5.5.2:compile
[INFO] |  +- org.apache.lucene:lucene-backward-codecs:jar:5.5.2:compile
[INFO] |  +- org.apache.lucene:lucene-analyzers-common:jar:5.5.2:compile
[INFO] |  +- org.apache.lucene:lucene-queries:jar:5.5.2:compile
[INFO] |  +- org.apache.lucene:lucene-memory:jar:5.5.2:compile
[INFO] |  +- org.apache.lucene:lucene-Highlighter:jar:5.5.2:compile
[INFO] |  +- org.apache.lucene:lucene-queryparser:jar:5.5.2:compile
[INFO] |  |  \- org.apache.lucene:lucene-sandBox:jar:5.5.2:compile
[INFO] |  +- org.apache.lucene:lucene-suggest:jar:5.5.2:compile
[INFO] |  |  \- org.apache.lucene:lucene-misc:jar:5.5.2:compile
[INFO] |  +- org.apache.lucene:lucene-join:jar:5.5.2:compile
[INFO] |  |  \- org.apache.lucene:lucene-grouping:jar:5.5.2:compile
[INFO] |  +- org.apache.lucene:lucene-spatial:jar:5.5.2:compile
[INFO] |  |  +- org.apache.lucene:lucene-spatial3d:jar:5.5.2:compile
[INFO] |  |  \- com.spatial4j:spatial4j:jar:0.5:compile
[INFO] |  +- org.elasticsearch:securesm:jar:1.0:compile
[INFO] |  +- com.carrotsearch:hppc:jar:0.7.1:compile
[INFO] |  +- com.fasterxml.jackson.dataformat:jackson-dataformat-smile:jar:2.8.1:compile
[INFO] |  +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.8.1:compile
[INFO] |  +- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.8.1:compile
[INFO] |  +- org.yaml:snakeyaml:jar:1.15:compile
[INFO] |  +- io.netty:netty:jar:3.10.6.Final:compile
[INFO] |  +- com.ning:compress-lzf:jar:1.0.2:compile
[INFO] |  +- com.tdunning:t-digest:jar:3.0:compile
[INFO] |  +- org.hdrhistogram:HdrHistogram:jar:2.1.6:compile
[INFO] |  +- commons-cli:commons-cli:jar:1.3.1:compile
[INFO] |  \- com.twitter:jsr166e:jar:1.1.0:compile
[INFO] +- org.elasticsearch:elasticsearch:jar:2.4.4:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.30:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] +- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] +- io.sentry:sentry-logback:jar:4.3.0:compile
[INFO] |  \- io.sentry:sentry:jar:4.3.0:compile
[INFO] +- com.abusix.util:rate-limiting-logback-filter:jar:0.1.0:compile

如果有人能给我提示可能是什么问题或如何更好地调试情况,我会非常高兴。

谢谢!

编辑 1:

正如评论中所建议的,我调试了 payara 并在 https://github.com/weld/core/blob/052861a964e78f2f65a97706fe1b181c9d7ce128/impl/src/main/java/org/jboss/weld/resources/ClassTransformer.java#L186 处放置了一个断点以找出原因(因为它显然没有正确登录到当前版本的 payara)。

原因是ClassNotFoundException

"java.lang.classNotFoundException: Whitelist enabled,but class [org.eclipse.microprofile.config.Config] is not whitelisted"

我会对此做进一步调查。

编辑 2:似乎对 microprofile.config 存在某种隐藏的依赖关系(不在我们的代码中,也没有在我们的一个依赖项中。至少不是明确地)。

它有助于添加

<dependency>
    <groupId>org.eclipse.microprofile.config</groupId>
    <artifactId>microprofile-config-api</artifactId>
    <version>2.0</version>
</dependency>

看看是否解决了所有问题,然后写下答案。

解决方法

我们设置了一个白名单来帮助解决一些类加载问题:https://blog.payara.fish/resolving-library-conflicts-with-class-whitelisting

在升级 payara 时,出于某种原因,我们现在依赖于 microprofile.Config 可用。

这可以通过将其添加到白名单来解决:

<glassfish-web-app>
  <whitelist-package>org.eclipse.microprofile</whitelist-package>
</glassfish-web-app>

或者添加api作为依赖:

<dependency>
    <groupId>org.eclipse.microprofile.config</groupId>
    <artifactId>microprofile-config-api</artifactId>
    <version>2.0</version>
</dependency>

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...