Classpath ordering prevents launching of specs test cases
With a .classpath generated from our build tool (Gradle), I'm unable to launch specs2 test cases using JUnit. I get the following error:
Steps to reproduce:
java.lang.NoClassDefFoundError: scala/ScalaObject
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
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 java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
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 java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
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 java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: scala.ScalaObject
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 java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 42 more
Steps to reproduce:
- git clone git://github.com/jeppenejsum/liftstart.git
- cd liftstart/
- ./gradlew eclipse
- Import the generated project into Eclipse, note it has the Scala nature and the "Scala Library"
- Navigate to src/test/scala/code/snippet/HelloWorldTest.scala file
- Right click the class name and select "Run As -> Junit test". This shows the error
- Now right click project and select "Scala -> Add Scala Library to build path". Note this changes the order of the libs.
- Run the test again, it now succeeds
Leave a comment
on 2012-05-08 09:11 *
By skyluc
Version changed from 2.0.0-final-28 to 2.1.0-nightly-29
Operative system changed from Mac OSX to All
Status changed from New to Accepted
This appears to be caused by the 'kind' of the Scala container. It is currently set to
Using the "Scala -> Add Scala Library to build path" command fixes the buildpath order, and resolve the problem.
Switching to
Regression tests would be needed for a complete fix.
IClasspathContainer.K_DEFAULT_SYSTEM
, which seems to mean that Eclipse will only add it to the bootstrap classpath part of the command line if the buildpath ordering requires it. Otherwise it assumes it is there by default.Using the "Scala -> Add Scala Library to build path" command fixes the buildpath order, and resolve the problem.
Switching to
IClasspathContainer.K_SYSTEM
instead seems to fix the problem (the scala library is always added to the bootstrap classpath).Regression tests would be needed for a complete fix.
(In scala-ide:1e308b47e6c6c905deaae19374ca979138f01159) Changed the 'kind' of the Scala library container
See re #1000919 for explanation about container kind.
Added a regression test.
Fix #1000798
Fix #1000919
Fix #1001022
Branch: master
See re #1000919 for explanation about container kind.
Added a regression test.
Fix #1000798
Fix #1000919
Fix #1001022
Branch: master
(In scala-ide:f49c749a78e58c18c5e7ec4ec92fb88941db87ef) Changed the 'kind' of the Scala library container
See re #1000919 for explanation about container kind.
Fix #1000798
Fix #1000919
Fix #1001022
(manually merged from 1e308b47e6c6c905deaae19374ca979138f01159)
Branch: release/scala-ide-2.0.x
See re #1000919 for explanation about container kind.
Fix #1000798
Fix #1000919
Fix #1001022
(manually merged from 1e308b47e6c6c905deaae19374ca979138f01159)
Branch: release/scala-ide-2.0.x
on 2012-06-28 16:00 *
By Mirco Dotta
Fixed in version set to 2.0.2
Eclipse version changed from Indigo to Indigo - Eclipse 3.7