Closed mdufresne closed 9 years ago
It looks like you are running your app though IntelliJ. How does that work with sbt? Also can you make sure you have a recent IntelliJ Scala plugin?
After I removed Global.java (Play2 Global Object), the error went away. Thoughts?
On Sat, Apr 11, 2015 at 10:19 PM, Eric Torreborre notifications@github.com wrote:
It looks like you are running your app though IntelliJ. How does that work with sbt? Also can you make sure you have a recent IntelliJ Scala plugin?
— Reply to this email directly or view it on GitHub https://github.com/etorreborre/specs2/issues/356#issuecomment-91994002.
My only supposition is that code was effectively compiled to the right place (in particular the ApplicationSpec
class) whereas it wasn't the case before. Well I'm glad it's working for you now :-).
java.lang.ClassNotFoundException: ApplicationSpec$
STACKTRACE java.net.URLClassLoader$1.run(URLClassLoader.java:366) java.net.URLClassLoader$1.run(URLClassLoader.java:355) java.security.AccessController.doPrivileged(Native Method) java.net.URLClassLoader.findClass(URLClassLoader.java:354) java.lang.ClassLoader.loadClass(ClassLoader.java:425) sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) java.lang.ClassLoader.loadClass(ClassLoader.java:358) org.specs2.reflect.Classes$$anonfun$loadClassEither$1.apply(Classes.scala:134) org.specs2.reflect.Classes$$anonfun$loadClassEither$1.apply(Classes.scala:134) org.specs2.control.ActionT$$anonfun$safe$1.apply(ActionT.scala:89) org.specs2.control.ActionT$$anonfun$reader$1$$anonfun$apply$6.apply(ActionT.scala:80) org.specs2.control.Status$.safe(Status.scala:100) org.specs2.control.StatusT$$anonfun$safe$1.apply(StatusT.scala:62) org.specs2.control.StatusT$$anonfun$safe$1.apply(StatusT.scala:62) scalaz.syntax.ToApplicativeOps$$anon$1.self$lzycompute(ApplicativeSyntax.scala:29) scalaz.syntax.ToApplicativeOps$$anon$1.self(ApplicativeSyntax.scala:29) scalaz.syntax.ToApplicativeOps$ApplicativeIdV$$anonfun$point$1.apply(ApplicativeSyntax.scala:33) scalaz.WriterTApplicative$$anonfun$point$1.apply(WriterT.scala:268) scalaz.WriterTApplicative$$anonfun$point$1.apply(WriterT.scala:268) scalaz.effect.IO$$anonfun$apply$19$$anonfun$apply$20.apply(IO.scala:136) scalaz.effect.IO$$anonfun$apply$19$$anonfun$apply$20.apply(IO.scala:136) scalaz.FreeFunctions$$anonfun$return$1.apply(Free.scala:326) scalaz.FreeFunctions$$anonfun$return$1.apply(Free.scala:326) scalaz.std.FunctionInstances$$anon$1$$anonfun$map$1.apply(Function.scala:56) scalaz.Free$$anonfun$run$1.apply(Free.scala:172) scalaz.Free$$anonfun$run$1.apply(Free.scala:172) scalaz.Free.go2$1(Free.scala:119) scalaz.Free.go(Free.scala:122) scalaz.Free.run(Free.scala:172) scalaz.effect.IO$class.unsafePerformIO(IO.scala:22) scalaz.effect.IOFunctions$$anon$6.unsafePerformIO(IO.scala:227) org.specs2.runner.Runner$.execute(Runner.scala:29) org.specs2.runner.ClassRunner$class.run(ClassRunner.scala:43) org.specs2.runner.ClassRunner$.run(ClassRunner.scala:84) org.specs2.runner.ClassRunner$class.run(ClassRunner.scala:25) org.specs2.runner.ClassRunner$.run(ClassRunner.scala:84) org.specs2.runner.NotifierRunner.main(NotifierRunner.scala:12) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:606) org.jetbrains.plugins.scala.testingSupport.specs2.JavaSpecs2Runner.runWithNotifierRunner(JavaSpecs2Runner.java:101) org.jetbrains.plugins.scala.testingSupport.specs2.JavaSpecs2Runner.runSpecs2_new(JavaSpecs2Runner.java:188) org.jetbrains.plugins.scala.testingSupport.specs2.JavaSpecs2Runner.runSingleTest(JavaSpecs2Runner.java:201) org.jetbrains.plugins.scala.testingSupport.specs2.JavaSpecs2Runner.main(JavaSpecs2Runner.java:84) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:606) com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
ApplicationSpec.scala
import org.specs2. import org.specs2.matcher. import org.specs2.specification.After import play.api.Play import play.api.libs.json.Json import play.api.test. import play.api.test.Helpers.
class ApplicationSpec extends Specification with JsonMatchers {
def is = args(sequential = true) ^ s2"""
This is a specification that tests the Application api endpoints
The api should send 404 on a bad request ${specTests.sendBadRequest} render index page ${specTests.getIndexPage} return newly created site with id ${specTests.createSite} update site document ${specTests.sendUpdatedSite} delete site document ${specTests.sendDeleteSite} """
object FakeApp extends FakeApplication
val specTests = AppSpecTest()
var testSiteId = 12
case class AppSpecTest() extends After { Play.start(FakeApp)
}
}
build.sbt
import PlayKeys._
name := """PollwareAdmin"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.11.6"
resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"
//routesImport += "extensions.Binders._"
libraryDependencies ++= Seq( jdbc, anorm, cache, ws, "org.reactivemongo" %% "play2-reactivemongo" % "0.10.5.0.akka23", "org.specs2" %% "specs2-common" % "3.3.1" % "test", "org.specs2" %% "specs2-matcher" % "3.3.1" % "test", "org.specs2" %% "specs2-core" % "3.3.1" % "test", "org.specs2" %% "specs2-matcher-extra" % "3.3.1" % "test" )
scalacOptions in Test ++= Seq("-Yrangepos", "-feature", "-language:reflectiveCalls")
fork in run := true