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.
lein
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
;; 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.
Related guides
Clojure "Unable to resolve symbol" in CIFix the Clojure "Unable to resolve symbol: X in this context" compile error in CI when a symbol is not define…
Clojure "Syntax error compiling at" in CIFix the Clojure "Syntax error compiling at (file:line:col)" error in CI - unbalanced forms, bad arity, or inv…
Elixir "(CompileError) module is not available" in CIFix the Elixir "(CompileError) module X is not available" error in CI when code references a module that is n…