sbt test fails with NoClassDefFoundError

639 views
Skip to first unread message

Alexander Lehmann

unread,
Apr 11, 2011, 7:01:26 AM4/11/11
to simple-build-tool
Hi all,

on one of my machines I'm recently experiencing a strange issue when I
try to run "sbt test" for a project which works fine on every other
machine.
All targets work well except for test which fails with a

java.lang.NoClassDefFoundError: org/scalatools/testing/Framework
...

I'm using the standard sbt directory layout, the library is there and
it's no problem at all to run the same setup with maven. I've already
tried
- unsetting the CLASSPATH
- running sbt from the same directory and not from its default
location in ~/bin (including sbt's jar)
- manually running java -Xmx1024m -jar sbt-launcher.jar test
- uninstalling my local scala installation
- checking out the project into a new directory
- sbt update/reload/clean/"whatever"
- several java versions

I know this looks like a CLASSPATH problem very much yet I think
there's more to it. There's a thread (http://scala-programming-
language.1934581.n4.nabble.com/scala-tools-Sbt-scalatest-config-
problem-help-appreciated-td3228465.html) on the net from a user who's
possibly experiencing the same problem however no solution could be
found.

So, if by any chance you happen to have any idea of what I might be
doing wrong -- remember, it only fails on this very machine which is
why I'm pretty sure it's not the project itself what's causing the
problem -- please help.

Thanks in advance, regards,
Alexander

Mark Harrah

unread,
Apr 12, 2011, 10:21:11 AM4/12/11
to simple-b...@googlegroups.com

It is likely there is a jar on a classpath somewhere not managed by sbt. This jar might be scalatest (or whatever Scala library you are using), it might be in the Java extensions directory, it might be in project/lib, or some other place jars get picked up. Without a stack trace or more information about the build, it is hard to guess, but you might be able to infer which class needs the Framework class and isn't getting it. Then, at the 'console', you could try:

Class.forName("<guessed.class>").getProtectionDomain.getCodeSource.getLocation

to see where the jar is coming from.

-Mark

Alexander Lehmann

unread,
Apr 13, 2011, 3:06:40 AM4/13/11
to simple-build-tool
Hi Mark,

On 12 Apr., 16:21, Mark Harrah <dmhar...@gmail.com> wrote:
> It is likely there is a jar on a classpath somewhere not managed by sbt.  This jar might be scalatest (or whatever Scala library you are using), it might be in the Java extensions directory, it might be in project/lib, or some other place jars get picked up.  Without a stack trace or more information about the build, it is hard to guess, but you might be able to infer which class needs the Framework class and isn't getting it.  Then, at the 'console', you could try:
>
>   Class.forName("<guessed.class>").getProtectionDomain.getCodeSource.getLocat ion
>
> to see where the jar is coming from.

thanks for your hint. However, I still wasn't able to figure out
what's causing the problem. I've searched the whole disk for jars that
might accidentally cause erroneous behavior yet without success. So I
apologize in advance for posting sbt's whole output for `test-compile'
but maybe it helps in tracking down the problem:


[info] == test-compile ==
[info] Source analysis: 5 new/modified, 0 indirectly invalidated, 0
removed.
[info] == test-compile ==
java.lang.NoClassDefFoundError: org/scalatools/testing/Framework
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:
141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:296)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:296)
at xsbt.boot.BootFilteredLoader.loadClass(FilteredLoader.scala:19)
at java.lang.ClassLoader.loadClass(ClassLoader.java:296)
at java.lang.ClassLoader.loadClass(ClassLoader.java:296)
at sbt.FilteredLoader.loadClass(ClasspathUtilities.scala:180)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at xsbt.DualLoader.loadClass(DualLoader.scala:26)
at java.lang.ClassLoader.loadClass(ClassLoader.java:296)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at sbt.TestFramework.create(TestFramework.scala:32)
at sbt.BasicScalaProject$BaseCompileConfig$$anonfun$getFingerprints
$1.apply(DefaultProject.scala:213)
at sbt.BasicScalaProject$BaseCompileConfig$$anonfun$getFingerprints
$1.apply(DefaultProject.scala:213)
at scala.List.flatMap(List.scala:1132)
at scala.List.flatMap(List.scala:452)
at sbt.BasicScalaProject
$BaseCompileConfig.getFingerprints(DefaultProject.scala:213)
at sbt.BasicScalaProject
$TestCompileConfig.fingerprints(DefaultProject.scala:242)
at sbt.CompileConditional
$CompileAnalysisCallback.<init>(Conditional.scala:222)
at sbt.CompileConditional.analysisCallback(Conditional.scala:219)
at sbt.CompileConditional.analysisCallback(Conditional.scala:213)
at sbt.AbstractCompileConditional.execute(Conditional.scala:344)
at sbt.Conditional$class.run(Conditional.scala:43)
at sbt.AbstractCompileConditional.run(Conditional.scala:231)
at sbt.BasicScalaProject.sbt$BasicScalaProject$
$doCompile(DefaultProject.scala:260)
at sbt.BasicScalaProject$$anonfun$testCompileAction
$1.apply(DefaultProject.scala:275)
at sbt.BasicScalaProject$$anonfun$testCompileAction
$1.apply(DefaultProject.scala:275)
at sbt.TaskManager$Task.invoke(TaskManager.scala:62)
at sbt.impl.RunTask.doRun$1(RunTask.scala:77)
at sbt.impl.RunTask.runTask(RunTask.scala:85)
at sbt.impl.RunTask.run(RunTask.scala:32)
at sbt.impl.RunTask$.apply(RunTask.scala:17)
at sbt.impl.RunTask$.apply(RunTask.scala:16)
at sbt.Project$class.run(Project.scala:98)
at sbt.Project$class.act(Project.scala:129)
at sbt.BasicScalaProject.act(DefaultProject.scala:21)
at sbt.xMain$$anonfun$8.apply(Main.scala:530)
at sbt.xMain$$anonfun$8.apply(Main.scala:530)
at sbt.xMain.withAction(Main.scala:563)
at sbt.xMain.sbt$xMain$$handleAction(Main.scala:530)
at sbt.xMain.handleCommand(Main.scala:520)
at sbt.xMain.processAction(Main.scala:459)
at sbt.xMain.process$1(Main.scala:257)
at sbt.xMain.processArguments(Main.scala:266)
at sbt.xMain.startProject(Main.scala:107)
at sbt.xMain.run(Main.scala:84)
at sbt.xMain.run0$1(Main.scala:35)
at sbt.xMain.run(Main.scala:42)
at xsbt.boot.Launch$.run(Launch.scala:53)
at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:42)
at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:42)
at xsbt.boot.Launch$.launch(Launch.scala:57)
at xsbt.boot.Launch$.explicit(Launch.scala:42)
at xsbt.boot.Launch$.initialized(Launch.scala:38)
at xsbt.boot.Launch$.parsed(Launch.scala:31)
at xsbt.boot.Launch$.configured(Launch.scala:21)
at xsbt.boot.Launch$.apply(Launch.scala:16)
at xsbt.boot.Launch$.apply(Launch.scala:13)
at xsbt.boot.Boot$.runImpl(Boot.scala:24)
at xsbt.boot.Boot$.run(Boot.scala:19)
at xsbt.boot.Boot$.main(Boot.scala:15)
at xsbt.boot.Boot.main(Boot.scala)
Caused by: java.lang.ClassNotFoundException:
org.scalatools.testing.Framework
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 75 more
Error during sbt execution: java.lang.NoClassDefFoundError: org/
scalatools/testing/Framework

As you've guessed right I'm using scalatest (1.3). Furthermore, I'm on
a OS X machine with java 1.6 (plus I've tried all available Java
Developer Packages from Apple -- again, no success).

Thanks for your time,
Alexander
Reply all
Reply to author
Forward
0 new messages