首页 > 解决方案 > Test runs on command line, fails in Scala-IDE

问题描述

When right-click running a test class, Eclipse failed with

Caused by: java.lang.NoClassDefFoundError: scala/Product$class
    at org.scalatest.time.Days$.<init>(Units.scala:291)
    at org.scalatest.time.Days$.<clinit>(Units.scala)
    at org.scalatest.time.Span$.<init>(Span.scala:585)
    at org.scalatest.time.Span$.<clinit>(Span.scala)
    at org.scalatest.tools.Runner$.<init>(Runner.scala:779)
    at org.scalatest.tools.Runner$.<clinit>(Runner.scala)
    at org.scalatest.tools.Runner.main(Runner.scala)
    ... 6 more
Caused by: java.lang.ClassNotFoundException: scala.Product$class
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 13 more

Yet it ran in the command line with sbt test. The libraries have been updated as described in java.lang.NoClassDefFoundError: scala/Product$class.

This happened with the latest Scala IDE (4.7.0-vfinal-2017-09-29T14:34:02Z-Typesafe) with the patmat project from Coursera's scala course.

What is the cause and how can it be fixed?

Requested info

The Java Build Path is

java build path

标签: eclipsescalaunit-testingscala-ide

解决方案


Please use the Scala library version 2.11 as the other Scala based dependencies like scala-xml and scalatest are based on Scala library version 2.11


推荐阅读