wildfly 16,log4j 2.17.0,无此类字段错误:空字节数组

t3irkdon  于 2022-11-06  发布在  其他
关注(0)|答案(3)|浏览(169)

I get an error during wildfly startup with the following message:
NoSuchFieldError: EMPTY_BYTE_ARRAY
The message also say that this error occurs in undertow deployment. Could anybody give me a hint of what is going on here and how to solve that?
Below is the beginning of the stack trace.

at org.wildfly.extension.undertow@24.0.1.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:90)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at java.base/java.lang.Thread.run(Thread.java:829)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.JBossThread.run(JBossThread.java:513)

Caused by: java.lang.NoSuchFieldError: EMPTY_BYTE_ARRAY at deployment.taggable-server.war//org.apache.logging.log4j.core.config.ConfigurationSource.(ConfigurationSource.java:56) at deployment.taggable-server.war//org.apache.logging.log4j.core.config.NullConfiguration.(NullConfiguration.java:32) at deployment.taggable-server.war//org.apache.logging.log4j.core.LoggerContext.(LoggerContext.java:85) at deployment.taggable-server.war//org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.createContext(ClassLoaderContextSelector.java:254) at deployment.taggable-server.war//org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:218) at deployment.taggable-server.war//org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:136) at deployment.taggable-server.war//org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:123) at deployment.taggable-server.war//org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:117) at deployment.taggable-server.war//org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:150) at deployment.taggable-server.war//org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:47) at org.apache.logging.log4j.api@2.14.1//org.apache.logging.log4j.LogManager.getContext(LogManager.java:196) at org.apache.logging.log4j.api@2.14.1//org.apache.logging.log4j.LogManager.getLogger(LogManager.java:599)

eufgjt7s

eufgjt7s1#

我遇到过同样的问题,可以这样解决它:
1.对于war
src/main/webapp/WEB-INF/中包含jboss-deployment-structure.xml,如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
  <deployment>
     <exclusions>
        <module name="org.apache.logging.log4j.api"/>
    </exclusions>
  </deployment>
</jboss-deployment-structure>

1.对于ear
src/main/application/META-INF/中包含jboss-deployment-structure.xml,如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
  <sub-deployment name="mywar.war">
     <exclusions>
        <module name="org.apache.logging.log4j.api"/>
    </exclusions>
  </sub-deployment>
</jboss-deployment-structure>
yvfmudvl

yvfmudvl2#

您需要从您的部署中排除API模块。您的另一个选择是使用WildFly 26,其中包含2.16版本的API。

p1iqtdky

p1iqtdky3#

请将log4j和log4j-api更新至2.16.0版。
如果您使用的是spring-boot so,请在pom.xml中添加标记

<properties> 
    <log4j2-version>2.16.0</log4j2-version>
  </properties>

<dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.16.0</version>
        </dependency>

在pom.xml中

相关问题