[ 
https://issues.apache.org/jira/browse/LOG4J2-2956?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17226699#comment-17226699
 ] 

Rafał Figas commented on LOG4J2-2956:
-------------------------------------

Well, strange thing is that ADDING new dependency causes NoClassDefFoundError 
on something that worked perfectly fine before that addition.

 

I am using latest Spring Boot 2.3.4.RELEASE with Java 11 and Spring Cloud 
Hoxton.RELEASE

I've checked befor submitting bug, that all log4j dependecies are 2.13.3 
version.

My current dependency list is as follows (this is directly from jar file):
{noformat}
HdrHistogram-2.1.12.jar
JavaEWAH-1.1.6.jar
LatencyUtils-2.0.3.jar
bcpkix-jdk15on-1.60.jar
bcprov-jdk15on-1.60.jar
commons-codec-1.14.jar
commons-logging-1.2.jar
httpclient-4.5.12.jar
httpcore-4.4.13.jar
jackson-annotations-2.11.2.jar
jackson-core-2.11.2.jar
jackson-databind-2.11.2.jar
jackson-dataformat-yaml-2.11.2.jar
jackson-datatype-jdk8-2.11.2.jar
jackson-datatype-jsr310-2.11.2.jar
jackson-module-parameter-names-2.11.2.jar
jakarta.annotation-api-1.3.5.jar
jakarta.el-3.0.3.jar
jsch-0.1.54.jar
jul-to-slf4j-1.7.30.jar
jzlib-1.1.1.jar
log4j-api-2.13.3.jar
log4j-core-2.13.3.jar
log4j-docker-2.13.3.jar
log4j-jul-2.13.3.jar
log4j-slf4j-impl-2.13.3.jar
log4j-spring-cloud-config-client-2.13.3.jar
micrometer-core-1.5.5.jar
org.eclipse.jgit-5.1.3.201810200350-r.jar
org.eclipse.jgit.http.apache-5.1.3.201810200350-r.jar
slf4j-api-1.7.30.jar
snakeyaml-1.26.jar
spring-aop-5.2.9.RELEASE.jar
spring-beans-5.2.9.RELEASE.jar
spring-boot-2.3.4.RELEASE.jar
spring-boot-actuator-2.3.4.RELEASE.jar
spring-boot-actuator-autoconfigure-2.3.4.RELEASE.jar
spring-boot-autoconfigure-2.3.4.RELEASE.jar
spring-boot-configuration-processor-2.3.4.RELEASE.jar
spring-boot-starter-2.3.4.RELEASE.jar
spring-boot-starter-actuator-2.3.4.RELEASE.jar
spring-boot-starter-json-2.3.4.RELEASE.jar
spring-boot-starter-log4j2-2.3.4.RELEASE.jar
spring-boot-starter-tomcat-2.3.4.RELEASE.jar
spring-boot-starter-web-2.3.4.RELEASE.jar
spring-cloud-commons-2.2.0.RELEASE.jar
spring-cloud-config-client-2.2.0.RELEASE.jar
spring-cloud-config-server-2.2.0.RELEASE.jar
spring-cloud-context-2.2.0.RELEASE.jar
spring-context-5.2.9.RELEASE.jar
spring-context-support-5.2.9.RELEASE.jar
spring-core-5.2.9.RELEASE.jar
spring-expression-5.2.9.RELEASE.jar
spring-jcl-5.2.9.RELEASE.jar
spring-security-crypto-5.3.4.RELEASE.jar
spring-security-rsa-1.0.7.RELEASE.jar
spring-web-5.2.9.RELEASE.jar
spring-webmvc-5.2.9.RELEASE.jar
tomcat-embed-core-9.0.38.jar
tomcat-embed-websocket-9.0.38.jar{noformat}

> Using log4j-spring-cloud-config-client and DynamicThresholdFilter cause Could 
> not initialize class 
> org.apache.logging.log4j.core.impl.ContextDataFactoryException
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-2956
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2956
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Spring
>    Affects Versions: 2.13.3
>            Reporter: Rafał Figas
>            Priority: Major
>
> Assumptions:
>  # Application is a Spring Boot app.
>  # {{It is configured to use spring-boot-starter-log4j2}}
> {{There is a log4j2.cfg.xml provided through logging.config property and it 
> is working fine. It contains following part:}}
>  
> {noformat}
> <DynamicThresholdFilter key="X-Log-Level" onMatch="ACCEPT" 
> onMismatch="NEUTRAL">   
>  <DefaultThreshold>INFO</DefaultThreshold>
>  <KeyValuePair key="DEBUG" value="DEBUG" />
>  <KeyValuePair key="TRACE" value="TRACE" />
> </DynamicThresholdFilter>{noformat}
> {{However when dependency log4j-spring-cloud-config-client is added 
> application does not start with following exception:}}
> {noformat}
> Exception in thread "main" java.lang.NoClassDefFoundError: Could not 
> initialize class 
> org.apache.logging.log4j.core.impl.ContextDataFactoryException in thread 
> "main" java.lang.NoClassDefFoundError: Could not initialize class 
> org.apache.logging.log4j.core.impl.ContextDataFactory 
> at 
> org.apache.logging.log4j.core.impl.ThreadContextDataInjector$ForDefaultThreadContextMap.rawContextData(ThreadContextDataInjector.java:137)
>  
> at 
> org.apache.logging.log4j.core.filter.DynamicThresholdFilter.currentContextData(DynamicThresholdFilter.java:162)
>  
> at 
> org.apache.logging.log4j.core.filter.DynamicThresholdFilter.filter(DynamicThresholdFilter.java:152)
>  at 
> org.apache.logging.log4j.core.Logger$PrivateConfig.filter(Logger.java:609) 
> at org.apache.logging.log4j.core.Logger.isEnabled(Logger.java:258) at 
> org.apache.logging.log4j.spi.AbstractLogger.isEnabled(AbstractLogger.java:1513)
>  
> at 
> org.apache.commons.logging.LogAdapter$Log4jLog.isErrorEnabled(LogAdapter.java:175)
>  at 
> org.springframework.boot.SpringApplication.reportFailure(SpringApplication.java:836)
>  
> at 
> org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:812)
>  at 
> org.springframework.boot.SpringApplication.run(SpringApplication.java:325) 
> at 
> org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) 
> at 
> org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) 
> at 
> pl.frati.moray.configserver.ConfigServerApplication.main(ConfigServerApplication.java:12)
> {noformat}
> First of all I have no idea what is missing. Without mentioned dependency 
> application startup is correct. Also, removing DynamicThresholdFilter solves 
> the problem as well.
> Second of all it seems that exception message is somewhat broken, because it 
> does not say anything about what class is missing. I've tried to debug this, 
> but class ContextDataFactory is pretty hard to debug. Fix in exception 
> message should ease the hunt.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to