I'm starting a new project using Scalatra and when trying to build the process the compiler says:
[info] Compiling 13 Scala sources to /home/mauricio/projects/scala/id2-search-proxy/target/scala-2.11/classes...
[error] missing or invalid dependency detected while loading class file 'ScalatraServlet.class'.
[error] Could not access term servlet in package javax,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'ScalatraServlet.class' was compiled against an incompatible version of javax.
[error] missing or invalid dependency detected while loading class file 'ScalatraServlet.class'.
[error] Could not access type HttpServlet in value javax.http,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'ScalatraServlet.class' was compiled against an incompatible version of javax.http.
[error] missing or invalid dependency detected while loading class file 'DynamicScope.class'.
[error] Could not access term servlet in package javax,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'DynamicScope.class' was compiled against an incompatible version of javax.
[error] missing or invalid dependency detected while loading class file 'RequestResponseScope.class'.
[error] Could not access term servlet in package javax,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'RequestResponseScope.class' was compiled against an incompatible version of javax.
[error] missing or invalid dependency detected while loading class file 'ScalatraContext.class'.
[error] Could not access term servlet in package javax,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'ScalatraContext.class' was compiled against an incompatible version of javax.
[error] missing or invalid dependency detected while loading class file 'DynamicScope.class'.
[error] Could not access type HttpServletResponse in value javax.http,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'DynamicScope.class' was compiled against an incompatible version of javax.http.
[error] missing or invalid dependency detected while loading class file 'DynamicScope.class'.
[error] Could not access type HttpServletRequest in value javax.http,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'DynamicScope.class' was compiled against an incompatible version of javax.http.
[error] missing or invalid dependency detected while loading class file 'SessionSupport.class'.
[error] Could not access term servlet in package javax,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'SessionSupport.class' was compiled against an incompatible version of javax.
[error] missing or invalid dependency detected while loading class file 'SessionSupport.class'.
[error] Could not access type HttpSession in value javax.http,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'SessionSupport.class' was compiled against an incompatible version of javax.http.
[error] missing or invalid dependency detected while loading class file 'ServletApiImplicits.class'.
[error] Could not access term servlet in package javax,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'ServletApiImplicits.class' was compiled against an incompatible version of javax.
[error] missing or invalid dependency detected while loading class file 'Route.class'.
[error] Could not access term servlet in package javax,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'Route.class' was compiled against an incompatible version of javax.
[error] missing or invalid dependency detected while loading class file 'ScalatraServlet.class'.
[error] Could not access type ServletConfig in value javax.servlet,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'ScalatraServlet.class' was compiled against an incompatible version of javax.servlet.
[error] missing or invalid dependency detected while loading class file 'ServletApiImplicits.class'.
[error] Could not access type ServletContext in value javax.servlet,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'ServletApiImplicits.class' was compiled against an incompatible version of javax.servlet.
[error] missing or invalid dependency detected while loading class file 'ServletApiImplicits.class'.
[error] Could not access type HttpSession in value javax.http,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'ServletApiImplicits.class' was compiled against an incompatible version of javax.http.
[error] missing or invalid dependency detected while loading class file 'ServletApiImplicits.class'.
[error] Could not access type HttpServletResponse in value javax.http,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'ServletApiImplicits.class' was compiled against an incompatible version of javax.http.
[error] missing or invalid dependency detected while loading class file 'ServletApiImplicits.class'.
[error] Could not access type HttpServletRequest in value javax.http,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'ServletApiImplicits.class' was compiled against an incompatible version of javax.http.
[error] 16 errors found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 6 s, completed 23/09/2015 13:03:32
I can't find these broken references anywhere at the scalatra source code or at the files I have here, all imports look right. Any idea what's going on here?
My SBT file is like this:
name := "id2-search-proxy"
version := "1.0"
scalaVersion := "2.11.7"
lazy val versions = new {
val scalatra = "2.4.0-RC2-2"
val specs2 = "3.6.4-20150916230958-8339115"
}
resolvers ++= Seq(
Resolver.sonatypeRepo("releases"),
"Twitter Maven" at "https://maven.twttr.com"
)
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.1.3"
libraryDependencies += "com.ning" % "async-http-client" % "1.9.31"
libraryDependencies += "commons-io" % "commons-io" % "2.4"
libraryDependencies += "io.argonaut" %% "argonaut" % "6.1-M4"
libraryDependencies += "oauth.signpost" % "signpost-core" % "1.2.1.2"
libraryDependencies += "oauth.signpost" % "signpost-commonshttp4" % "1.2.1.2"
libraryDependencies += "org.mockito" % "mockito-core" % "1.10.19" % Test
libraryDependencies += "org.specs2" %% "specs2-core" % versions.specs2 % Test
libraryDependencies += "org.specs2" %% "specs2-mock" % versions.specs2 % Test
libraryDependencies += "org.scalatra" %% "scalatra" % versions.scalatra
libraryDependencies += "org.scalatra" %% "scalatra-specs2" % versions.scalatra % Test
resolvers += "twitter-repo" at "http://maven.twttr.com/"
resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"
scalacOptions in Test ++= Seq("-Yrangepos", "-Ylog-classpath")
Since servlet-api was set to provided it would be loaded on Idea but wouldn't be available during compilation, directly depending on it fixed the issue:
libraryDependencies += "javax.servlet" % "javax.servlet-api" % "3.1.0"
Related
I am new to scalatest and scalamock. Here is what I have it in my sbt file
name := "cakepattern"
version := "0.1"
scalaVersion := "2.11.8"
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.0.0" % "test",
"org.scalamock" %% "scalamock-core" % "3.1.1" % "test",
"org.scalamock" %% "scalamock-scalatest-support" % "3.1.1" % "test",
"org.scalacheck" %% "scalacheck" % "1.13.0" % "test"
)
And here is a class that I am trying to mock
package config
import dto.User
import services.AuthServiceComponent
import org.scalatest.mockito.MockitoSugar._
import services.impl.DefaultUserAuthServiceComponent
trait MockAuthServiceComponent extends AuthServiceComponent{
val x = mock[AuthServiceLike]
type AuthService = x.type
override val userAuthService = x
}
When I am do sbt test:compile I get the following error
[error] missing or invalid dependency detected while loading class file 'MockitoSugar.class'.
[error] Could not access term mockito in package org,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'MockitoSugar.class' was compiled against an incompatible version of org.
[error] missing or invalid dependency detected while loading class file 'MockitoSugar.class'.
[error] Could not access type MockSettings in value org.mockito,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'MockitoSugar.class' was compiled against an incompatible version of org.mockito.
[error] missing or invalid dependency detected while loading class file 'MockitoSugar.class'.
[error] Could not access type Answer in value org.stubbing,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'MockitoSugar.class' was compiled against an incompatible version of org.stubbing.
[error] three errors found
[error] (test:compileIncremental) Compilation failed
What am I missing?
[Edit]
So the problem I was having before is resolved but now I get this
Error:scalac: missing or invalid dependency detected while loading class file 'AbstractMockFactory.class'.
Could not access type NoArgTest in trait org.scalatest.Suite,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'AbstractMockFactory.class' was compiled against an incompatible version of org.scalatest.Suite.
Any suggestions?
Try adding Mockito to your sbt file:
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.0.0" % Test,
"org.scalamock" %% "scalamock-core" % "3.1.1" % Test,
"org.scalamock" %% "scalamock-scalatest-support" % "3.1.1" % Test,
"org.scalacheck" %% "scalacheck" % "1.13.0" % Test,
"org.mockito" % "mockito-all" % "1.10.19" % Test
)
Take care, it's a simple "%", not a double one (it's a java dependency)
Other versions here : https://mvnrepository.com/artifact/org.mockito/mockito-all if 1.10.19 is not compatible with your codebase
EDIT :
Not sure that will help your second problem, but try that in an SBT console :
> clean
> compile
Versions <3.3.0 are not compatible with Scalatest 3+.
I suggest updating to scalamock 3.4.2 (latest one as of writing).
You can always find the newest version on Maven Central.
Also, no need to specify scalamock-core, that gets pulled in automatically.
scalacheck 3.2 depend on scalatest 2.1.3, but you used scalatest 3.0.0, so they are not compatibal. remove the scalatest dependence will resolve the problem.
When I try to run ( through SBT) my scala program I run into a bunch of errors.
Here's an excerpt:
[error] missing or invalid dependency detected while loading class file 'IterableUtils.class'.
[error] Could not access type ScalaObject in package scala,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'IterableUtils.class' was compiled against an incompatible version of scala.
[error] missing or invalid dependency detected while loading class file 'AsBooleanTrait.class'.
[error] Could not access type ScalaObject in package scala,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
.....
I did add the scala-library.jar to the classpath but to no avail. Does anyone know what might be missing?
Ps. used -> new SBT project (Intellij) on osx
edit: here's the build.sbt
name := "test"
version := "1.0"
scalaVersion := "2.11.8"
resolvers += "Scales XML" at "https://mvnrepository.com/artifact/org.scalesxml/scales-xml_2.9.1"
libraryDependencies += "org.scalesxml" % "scales-xml_2.9.1" % "0.3-RC7"
SBT is version 0.13.8
Edit 2:
Figured it out. I was trying to run a class (with a main method) without creating an instance... After changing it to an Object things work a lot better :)
Edit 3:
Spoke too soon. I turns out it has to do with setting the scalaVersion in build.sbt. When I leave that entire line out, it no longer complains about the missing dependencies. When I put it back in I get the errors mentioned above back. I tried setting it to 2.11.7 as well ( after installing that with brew install scala) but to no avail.
scalaVersion := "2.11.8"
libraryDependencies += "org.scalesxml" % "scales-xml_2.9.1" % "0.3-RC7"
You can't use a library compiled for Scala 2.9.1 with Scala 2.11.*. Write "org.scalesxml" %% "scales-xml" % some-version instead, which will look for scales-xml_2.11. See http://www.scala-sbt.org/0.13/docs/Cross-Build.html.
Every now and then I start things from scratch to make sure I know what all the intricate details of setting up a project are. I have a simple app like the following but I get some dependency issues that don't seem to point me anywhere. I'm using scala verions 2.11.
My SBT:
name := "Helios"
version := "1.0"
scalaVersion := "2.11.8"
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
libraryDependencies ++= Seq(
"com.typesafe.akka" % "akka-actor" % "2.0.2",
"com.typesafe.akka" % "akka-slf4j" % "2.0.5")
My Sample Class
import com.echostar.ese.helios.core.Asset
import akka.actor._
class NSPSG extends Actor {
def receive = {
case a: Asset => {
println(s"NSPSG Received asset: ${a}")
}
case _ => println("Unexpected message received")
}
}
(Asset class is just a case class with id and title in it.)
Error Message:
C:\PROJECTS\active\Helios>sbt compile
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] Loading global plugins from C:\Users\dana.murad\.sbt\0.13\plugins
[info] Loading project definition from C:\PROJECTS\active\Helios\project
[info] Set current project to Helios (in build file:/C:/PROJECTS/active/Helios/)
[info] Updating {file:/C:/PROJECTS/active/Helios/}helios...
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[info] Compiling 3 Scala sources to C:\PROJECTS\active\Helios\target\scala-2.11\classes...
[error] missing or invalid dependency detected while loading class file 'package.class'.
[error] Could not access type ScalaObject in package scala,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'package.class' was compiled against an incompatible version of scala.
[error] missing or invalid dependency detected while loading class file 'Actor.class'.
[error] Could not access type ScalaObject in package scala,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'Actor.class' was compiled against an incompatible version of scala.
[error] C:\PROJECTS\active\Helios\src\main\scala\com\echostar\ese\helios\workers\NSPSG.scala:9: illegal inheritance;
[error] self-type com.echostar.ese.helios.workers.NSPSG does not conform to akka.actor.Actor's selftype akka.actor.Actor
[error] class NSPSG extends Actor {
[error] ^
[error] three errors found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 3 s, completed Apr 4, 2016 9:19:45 AM
My main App is just a println for now. It's not even calling this actor.
Am I using the wrong version of akka with scala 2.11? -Ylog-classpath didn't help
Don't know what fixed it but here's a list of things I did and the project compiles now.
Changed akka dependency line to this (added double percent and changed version back to 2.4)
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.4.0"
)
Removed my Run configuration and added it back again. ( I think the path to main showed as red (invalid) so redoing it helped resolve it. I changed my package name and I don't think intelliJ picked up the rename well in build-conf)
Started another test project from IntelliJ menu (Akka Main in Scala) and that took a bit to download all dependencies. So maybe my project needed those and wasn't download them?
Removed commented out lines (got rid of a semi-colon). I don't think this did anything but full disclosure, technically I did touch the code even though my actor definition is exactly the same.
I am trying to update play to 2.3 from 2.2, but I got several errors complaining about DefaultReads incompatible.
[error] Could not access term time in package java,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'DefaultReads.class' was compiled against an incompatible version of java.
[error] (jsObj \ "items").asOpt[JsArray] match {
The problem is play-cache dependency. I shouldn't use the latest one. After I use the one matched with Play version, it works.
"com.typesafe.play" % "play-cache_2.11" % "2.3.8"
As suggested by #richard-close, the issue was caused in my case by having a jdk7 used by sbt.
You can check that with
sbt
> eval System.getProperty("java.version")
[info] ans: String = 1.7.0_80
> eval System.getProperty("java.home")
[info] ans: String = /usr/lib/jvm/java-7-oracle/jre
I'm new to Scala and SBT so I might be missing something obvious.
I was trying to compile the HelloWorld example on http://www.scalafx.org/docs/quickstart/
I created a file build.sbt containing:
scalaVersion := "2.11.5"
libraryDependencies += "org.scalafx" %% "scalafx" % "8.0.0-R4"
and a file src/main/scala/ScalaFXHelloWorld.scala containing the code from linked page.
However, when running sbt run I get:
OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=256M; support was removed in 8.0
[info] Set current project to scalafx (in build file:/home/kvbx/Projects/ScalaFX/)
[info] Compiling 1 Scala source to /home/kvbx/Projects/ScalaFX/target/scala-2.11/classes...
[error] missing or invalid dependency detected while loading class file 'Color.class'.
[error] Could not access term javafx in package <root>,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'Color.class' was compiled against an incompatible version of <root>.
[error] missing or invalid dependency detected while loading class file 'Color.class'.
[error] Could not access term scene in value javafx,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'Color.class' was compiled against an incompatible version of javafx.
[error] missing or invalid dependency detected while loading class file 'Stage.class'.
[error] Could not access term javafx in package <root>,
...
...
I'm running sbt 0.13.7 and scala 2.11.5 on openjdk 1.8.0_31 on Archlinux
JavaFX isn't part of OpenJDK 8. I installed openjfx. Works. (Thanks Jasper)