Andrejus Chaliapinas commented on LOG4J2-2266:

I'm trying to minimize some code and did now directly such in my test class 
within static {} clause to mimic what Log4j2 was trying to do:

try {
  PropertiesUtil PROPS = new PropertiesUtil("log4j2.StatusLogger.properties");
} catch (Throwable e) {


and got upper stack as reported for this bug, but actual root cause like such:

org.apache.logging.log4j.util.PropertySource: Provider 
org.apache.logging.log4j.util.EnvironmentPropertySource not a subtype
        at java.util.ServiceLoader.fail(ServiceLoader.java:239)
        at java.util.ServiceLoader.access$300(ServiceLoader.java:185)
        at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
        at java.util.ServiceLoader$1.next(ServiceLoader.java:480)


and that brings me back to where I've started looking into similar issues 
initially for v2.9.1, i.e. LOG4J2-2055.

I cannot provide test project out of my complex code, but I think issue now 
should be more or less clear.


And line 375 inside ServiceLoader class for JDK8 is:

if (!service.isAssignableFrom(c)) {
         "Provider " + cn  + " not a subtype");


So if Log4j2 v2.10.0 is supposed to still work with JDK8 as before - we need to 
fix this obviously. if you may have some patch to try in form of jar with 
compiled classes - I could do that, cause not yet using JDK9 to build things 


> Log4j2 throws NoClassDefFoundError in Java 8
> --------------------------------------------
>                 Key: LOG4J2-2266
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2266
>             Project: Log4j 2
>          Issue Type: Bug
>    Affects Versions: 2.10.0
>            Reporter: Andrejus Chaliapinas
>            Priority: Major
> During Unit Tests run using JDK 8 and Log4j2 v2.10.0 - getting this as part 
> of exception stack:
> java.lang.NoClassDefFoundError: Could not initialize class 
>  org.apache.logging.log4j.util.PropertiesUtil
>      at 
> org.apache.logging.log4j.status.StatusLogger.<clinit>(StatusLogger.java:71)
>      at org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:60)
> and issue seems to be somehow related to what is reported so far against JDK 
> 9 here: LOG4J2-2129.
> If some patch on top of v2.10.0 is available to test - please let me know 
> where to download it from.
> While running same UTs with same JDK 8 and v2.8.2 - issue is not observed.
> And question which I have here - why not introduce JDK8 compatibility runtime 
> mode while things with JDK9 are not yet that stable? So it could continue use 
> same logic as of v2.8.2 around that ServiceLoader and not cause side effects.

This message was sent by Atlassian JIRA

Reply via email to