Skip to content
Latchkey

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.ObjectMapper

Common 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

  1. Confirm the fully qualified class name in :import.
  2. Run lein deps so the dependency is fetched.
  3. Clean stale AOT output with lein clean before 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →