Clojure "ClassNotFoundException" in CI
Clojure tried to load a Java class that is not on the classpath. The dependency providing it is missing, or the import names the wrong class.
What this error means
Compilation or runtime fails with java.lang.ClassNotFoundException: com.example.Widget, naming the class. It is deterministic given the classpath.
Syntax error (ClassNotFoundException) compiling at (app.clj:4:1).
java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.ObjectMapperCommon causes
Dependency providing the class is missing
The Java library that contains the class is not in project.clj/deps.edn, so the class is absent from the classpath.
Wrong class name in import
The :import names a class that does not exist (wrong package or typo).
AOT/classpath mismatch
A stale compiled class or a classpath that differs between local and CI leaves the class unavailable in CI.
How to fix it
Add the dependency that provides the class
;; project.clj
:dependencies [[com.fasterxml.jackson.core/jackson-databind "2.17.0"]]Fix the import and classpath
- Confirm the fully qualified class name in :import.
- Run
lein depsso the dependency is fetched. - Clean stale AOT output with
lein cleanbefore building.
How to prevent it
- Keep dependencies in sync with :import statements.
- Run lein clean before AOT builds.
- Verify the classpath matches between local and CI.