1

I am getting a no class definition found for org/apache/logging/log4j/util/ReflectionUtil.

I excluded the log4j-core version 2.4.1 that is included with spring boot 1.3.8 and want to substitute it with 2.17.1.

My understanding is ReflectionUtil should be in either log4j-core or log4j-api.

Why am I still getting the exception of ClassDefinitionNotFound?

Thanks!

Karl

Snippet of the related section of my pom.xml file below.

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-log4j2</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.17.1</version>
    </dependency>

    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>2.17.1</version>
    </dependency>
Karl Ninh
  • 11
  • 3
  • does the class `ReflectionUtil` exist in 2.17.1? – Michael McFadyen Jan 05 '22 at 21:56
  • Does this answer your question? [I'm getting "NoClassDefFoundError: org/apache/logging/log4j/util/ReflectionUtil"](https://stackoverflow.com/questions/52700803/im-getting-noclassdeffounderror-org-apache-logging-log4j-util-reflectionutil) – Michael McFadyen Jan 05 '22 at 21:59
  • Unfortunately that link does not answer my question. The class ReflectionUtil was moved from log4j-core to log4j-api. When I did a show table of content for log4j-api jar file, I do see the ReflectionUtil.class in that jar. Just not sure why it is not visible/available to the junit at runtime. jar tf log4j-core-2.17.1.jar | grep ReflectionUtil org/apache/logging/log4j/core/util/ReflectionUtil.class – Karl Ninh Jan 05 '22 at 22:26
  • 1
    which is under a different package to `org/apache/logging/log4j/util/ReflectionUtil`, which is what appears in the exception. – Michael McFadyen Jan 05 '22 at 22:31
  • I see what you are saying Michael. Thank you! At least it gives me something to try to figure out. – Karl Ninh Jan 05 '22 at 22:44
  • 1
    This might be a tough one to swallow but you may need to upgrade to a supported spring boot version to be able to use log4j 2.17. It seems like the package of that class changed in log4j 2.9 and as a result the code inside spring boot will need to be updated so that the import matches. – Michael McFadyen Jan 05 '22 at 22:52
  • 2
    Thanks Michael! Yeah, it looks like I may not have much of a choice but to upgrade spring boot version. – Karl Ninh Jan 05 '22 at 22:55
  • Updating is a very good idea given the recent security exploit in log4j. – intotecho Jan 14 '22 at 07:05

0 Answers0