SECURITY WARNING: Never run commands you don't understand. Always review code before execution. Use at your own risk.
Scala New Added 12 September 2026

Scala: NoClassDefFoundError: scala/collection/IterableOnce

A jar built for a different Scala version is on the classpath. Scala is only binary compatible within a minor version, so a 2.12 artifact loaded by a 2.13 runtime looks for classes that were moved or renamed. It compiles, because the missing class is only resolved when the code first runs.

Quick fix

Read the commands before running them. Anything that restarts a service, deletes data or changes permissions should be tried on a non-production system first.

Quick fix
# Find the artifact that is cross built for the wrong version
sbt "show dependencyClasspath" | tr ',' '\n' | grep -E '_2\.1[0-3]'
sbt evicted

// Always let sbt append the suffix with %% rather than writing it yourself
libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.8.5"   // right
libraryDependencies += "com.typesafe.akka" % "akka-actor_2.12" % "2.8.5" // wrong

// Java only artifacts use a single % on purpose and are unaffected
libraryDependencies += "org.postgresql" % "postgresql" % "42.7.4"

# Spark pins the Scala version of the cluster: match it exactly
spark-submit --version

# Rule out a stale assembly jar before changing dependencies
sbt clean assembly
unzip -l target/scala-2.13/app-assembly.jar | grep IterableOnce

How to diagnose Scala errors

Scala's most distinctive error class is binary incompatibility: libraries are published per Scala major version, and mixing artifacts built for different versions produces confusing "not a member of" or NoSuchMethodError failures. The %% operator in sbt exists precisely to append the right suffix, and most unresolved-dependency errors are a % where %% was needed.

If the quick fix above does not resolve it, work through these steps. They apply to this whole class of error, not just to this one message, which is usually what saves the time.

  1. Check the Scala version suffix on every dependency. Use %% for Scala libraries and plain % only for Java ones.
  2. Run sbt evicted to list dependencies that were evicted by version conflict. A frequent source of runtime NoSuchMethodError.
  3. Use sbt dependencyTree to see the resolved graph and locate the transitive dependency pulling in an old version.
  4. For inference failures, add explicit type annotations at the boundary rather than at the error site; inference failures usually propagate from further up.
  5. Clear stale state with sbt clean and remove ~/.ivy2/cache or ~/.cache/coursier entries only for the specific failing artifact.

Tools worth reaching for

  • sbt evicted
  • sbt dependencyTree
  • coursier resolve
  • scalac -explain
  • MiMa (binary compat checks)

Authoritative references

Primary documentation for this error, worth reading before applying any fix in production.

docs.scala-lang.org

Related Scala errors

See all 6 Scala errors →

Browse other categories

Something missing or wrong?

This entry is maintained by hand. If the fix is out of date, incomplete, or you have a better one, email a correction and it will be reviewed.