Skip to content
Latchkey

Gradle wrapper "Could not find or load main class org.gradle.wrapper.GradleWrapperMain" (missing jar) in CI

./gradlew runs the tiny bootstrap jar gradle/wrapper/gradle-wrapper.jar. When that jar is missing from the checkout, the JVM cannot find GradleWrapperMain and the build fails before Gradle starts.

What this error means

Running ./gradlew fails with "Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain" even though gradlew and gradle-wrapper.properties are present.

Gradle
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
Caused by: java.lang.ClassNotFoundException: org.gradle.wrapper.GradleWrapperMain

Common causes

The wrapper jar was gitignored or never committed

A broad *.jar ignore rule or an incomplete gradle wrapper run left gradle-wrapper.jar out of the repository, so the checkout has no bootstrap class.

A shallow or filtered checkout dropped the jar

A sparse checkout or LFS filter excluded the binary jar, so it is absent on the runner.

How to fix it

Regenerate and commit the wrapper jar

  1. Run gradle wrapper locally to regenerate the full wrapper set.
  2. Force-add the jar past any ignore rule.
  3. Commit gradle/wrapper/gradle-wrapper.jar so CI can run ./gradlew.
Terminal
gradle wrapper --gradle-version 8.7
git add -f gradle/wrapper/gradle-wrapper.jar

Stop ignoring the wrapper jar

Exclude the wrapper jar from any *.jar ignore so it stays in version control.

.gitignore
# .gitignore
*.jar
!gradle/wrapper/gradle-wrapper.jar

How to prevent it

  • Commit gradle-wrapper.jar and exempt it from *.jar ignores.
  • Verify ./gradlew --version works on a fresh clone.
  • Use actions/checkout without sparse filters that drop the jar.

Related guides

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