Question

EDIT: This issue was a bug with sbteclipse and has been fixed

When I right click on a ScalaTest suite and select Run as ScalaTest File, I get a NullPointer Exception.

  • As a plugin, I have ScalaTest for Scala IDE 2.9.3.v-3-2_09-201309130843-55f5c32
  • As a jar in my library, I have scalatest_2.9.0-2.0.M5b.jar(tried scalatest_2.9.3-RC2-2.0.M5b.jar as well)
  • Tests run in SBT

Side Question: If it is a Scalatest compatibility issue between the jar and the plugin, how do I get the appropriate jar which matches the plugin? I looked here https://oss.sonatype.org/content/groups/public/org/scalatest/ but I don't know which one to pick.

java.lang.NullPointerException at scala.collection.mutable.ArrayOps$ofRef.length(ArrayOps.scala:115) at scala.collection.SeqLike$class.size(SeqLike.scala:100) at scala.collection.mutable.ArrayOps.size(ArrayOps.scala:38) at scala.collection.mutable.Builder$class.sizeHint(Builder.scala:69) at scala.collection.mutable.ArrayBuilder.sizeHint(ArrayBuilder.scala:23) at scala.collection.TraversableLike$class.map(TraversableLike.scala:232) at scala.collection.mutable.ArrayOps.map(ArrayOps.scala:38) at scala.tools.eclipse.scalatest.launching.ScalaTestLaunchDelegate.launchScalaTest(ScalaTestLaunchDelegate.scala:103) at scala.tools.eclipse.scalatest.launching.ScalaTestLaunchDelegate.launch(ScalaTestLaunchDelegate.scala:161) at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:854) at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:703) at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:937) at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1141) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

Other Details:

eclipse.buildId=M20120208-0800
java.version=1.7.0_40
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_CA
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os linux -ws gtk -arch x86 -product org.eclipse.epp.package.jee.product
Was it helpful?

Solution

Why this happens:

The error can happen if you use sbteclipse to create your eclipse config. sbteclipse uses the Scala Library which in your .ivy2 folder which may not be compatible with the scalatest plugin, and hence the error.

What I learnt after breaking my head and contemplating nuking my PC

Go to Project Properties -> Java Build Path -> Libraries Remove the generated scala library pointing to ivy use 'Add Library...' to add Scala Library that comes with the scala-ide, [Optional] make sure that the Run Configuration uses the bundled Scala Library also.

This solution is brought to you by Chee Seng

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top