Skip to content

'Getting java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory

The java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory exception is thrown when a Java application is unable to find the LogFactory class from the Apache Commons Logging library. This typically occurs when the dependency is missing from the classpath, or when there is a version conflict or shading issue.

To fix this exception, ensure the Apache Commons Logging library is in your classpath. The exact artifact coordinates are org.apache.commons:commons-logging:1.3.4.

Maven Add the following to your pom.xml:

xml
<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-logging</artifactId>
    <version>1.3.4</version>
</dependency>

Gradle Add the following to your build.gradle:

groovy
implementation 'org.apache.commons:commons-logging:1.3.4'

If the library is already in the classpath but you are still getting the ClassNotFoundException, check for dependency conflicts or shading issues. You can verify the resolved dependencies using your build tool:

  • Maven: mvn dependency:tree
  • Gradle: gradle dependencies

If a conflicting version is shaded or overridden, exclude it from the transitive dependency or explicitly declare the required version.

Do you find this helpful?

Dual-run preview — compare with live Symfony routes.