1
votes

When I run 'sbt test' I get: "[error] (test:executeTests) java.lang.NoClassDefFoundError: scala/collection/GenTraversableOnce$class"

I'm guessing that I'm running with a particular Scala version and ScalaTest is expecting a different Scala version. However why this happens, I don't know! I think I'm running with Scala 2.11 and that this is also with ScalaTest should be expecting.

Of interest might be that I'm not actually using ScalaTest. I'm only using JUnit tests.

The project can be found on GitHub. I'm using this sbt file:

name := "ParticleCompilerSbt"    
version := "1.0"    
scalaVersion := "2.11.8"

libraryDependencies += "com.fifesoft" % "rsyntaxtextarea" % "2.5.8"    
libraryDependencies += "org.swinglabs" % "swingx" % "1.6.1"    
libraryDependencies += "jgraph" % "jgraph" % "5.13.0.0"    
libraryDependencies += "org.tinyjee.jgraphx" % "jgraphx" % "2.3.0.5"    
libraryDependencies += "org.jgrapht" % "jgrapht-core" % "0.9.1"    
libraryDependencies += "org.scalatest" % "scalatest_2.11" % "3.0.0" % "test"    
libraryDependencies += "junit" % "junit" % "4.12" % "test"    
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test"    
libraryDependencies += "org.scala-lang" % "scala-compiler" % "2.11.8"    
libraryDependencies += "org.scala-lang.modules" % "scala-xml_2.11" % "1.0.5"    
libraryDependencies += "org.scala-lang.modules" % "scala-swing_2.11" % "2.0.0-M2"    
libraryDependencies += "org.scala-lang.modules" % "scala-parser-combinators_2.11" % "1.0.4"    
libraryDependencies += "org.apache.commons" % "commons-math3" % "3.5"    
libraryDependencies += "com.google.guava" % "guava" % "18.0"
libraryDependencies += "com.typesafe.akka" % "akka-actor_2.10" % "2.1.3"
unmanagedResourceDirectories in Compile += baseDirectory.value / "testResources"

'sbt test' gives the following stacktrace:

java.lang.NoClassDefFoundError: scala/collection/GenTraversableOnce$class
        at org.scalatest.ConfigMap.<init>(ConfigMap.scala:97)
        at org.scalatest.tools.Runner$.parsePropertiesArgsIntoMap(Runner.scala:2219)
        at org.scalatest.tools.Framework.runner(Framework.scala:1026)
        at sbt.Defaults$$anonfun$createTestRunners$1.apply(Defaults.scala:547)
        at sbt.Defaults$$anonfun$createTestRunners$1.apply(Defaults.scala:541)
        at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
        at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
        at scala.collection.immutable.Map$Map2.foreach(Map.scala:130)
        at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
        at scala.collection.AbstractTraversable.map(Traversable.scala:105)
        at sbt.Defaults$.createTestRunners(Defaults.scala:541)
        at sbt.Defaults$.allTestGroupsTask(Defaults.scala:561)
        at sbt.Defaults$$anonfun$testTasks$4.apply(Defaults.scala:424)
        at sbt.Defaults$$anonfun$testTasks$4.apply(Defaults.scala:424)
        at scala.Function9$$anonfun$tupled$1.apply(Function9.scala:35)
        at scala.Function9$$anonfun$tupled$1.apply(Function9.scala:34)
        at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
        at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
        at sbt.std.Transform$$anon$4.work(System.scala:63)
        at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
        at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
        at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
        at sbt.Execute.work(Execute.scala:237)
        at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
        at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
        at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
        at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: scala.collection.GenTraversableOnce$class
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at org.scalatest.ConfigMap.<init>(ConfigMap.scala:97)
        at org.scalatest.tools.Runner$.parsePropertiesArgsIntoMap(Runner.scala:2219)
        at org.scalatest.tools.Framework.runner(Framework.scala:1026)
        at sbt.Defaults$$anonfun$createTestRunners$1.apply(Defaults.scala:547)
        at sbt.Defaults$$anonfun$createTestRunners$1.apply(Defaults.scala:541)
        at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
        at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
        at scala.collection.immutable.Map$Map2.foreach(Map.scala:130)
        at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
        at scala.collection.AbstractTraversable.map(Traversable.scala:105)
        at sbt.Defaults$.createTestRunners(Defaults.scala:541)
        at sbt.Defaults$.allTestGroupsTask(Defaults.scala:561)
        at sbt.Defaults$$anonfun$testTasks$4.apply(Defaults.scala:424)
        at sbt.Defaults$$anonfun$testTasks$4.apply(Defaults.scala:424)
        at scala.Function9$$anonfun$tupled$1.apply(Function9.scala:35)
        at scala.Function9$$anonfun$tupled$1.apply(Function9.scala:34)
        at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
        at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
        at sbt.std.Transform$$anon$4.work(System.scala:63)
        at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
        at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
        at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
        at sbt.Execute.work(Execute.scala:237)
        at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
        at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
        at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
        at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

I've been stuck with this for a while so thanks for helping!

1

1 Answers

2
votes

This line:

libraryDependencies += "com.typesafe.akka" % "akka-actor_2.10" % "2.1.3"

You're loading in a dependency depending on scala 2.10. I tried upgrading it to the latest version (2.4.11) but it seems like there were breaking changes which removed the akka.util.Convert package. You may need to find where they moved the functionality or write the utility function yourself.

Also for scala dependencies I'd recommend using %% instead of % and sbt will automatically append the correct scala verion for you. i.e. instead of

libraryDependencies += "org.scala-lang.modules" % "scala-xml_2.11" % "1.0.5"

you do

libraryDependencies += "org.scala-lang.modules" %% "scala-xml" % "1.0.5"

EDIT: I think ByteStringBuilder in akka.util.ByteString is the replacement.