Unresolved dependency when Scalatest used with Spark - scala

My dependencies in build.sbt is as follows
scalaVersion := "2.11.8"
ibraryDependencies ++= Seq(
"org.apache.spark" % "spark-core_2.11" % "2.1.0" %"provided" ,
"org.apache.spark" % "spark-sql_2.11" % "2.1.0" %"provided" ,
"org.scalatest" %%"scalatest" % "2.0" %"test"
}
when i build project i got below error
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.scalatest#scalatest_2.11;2.0: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Unresolved dependencies path:
[warn] org.scalatest:scalatest_2.11:2.0
[warn] +- transformer:transformer_2.11:1.0
sbt.ResolveException: unresolved dependency: org.scalatest#scalatest_2.11;2.0: not found
at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:313)
at sbt.IvyActions$$anonfun$updateEither$1.apply(IvyActions.scala:191)
at sbt.IvyActions$$anonfun$updateEither$1.apply(IvyActions.scala:168)
at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:156)
though it work fine if i remove the provided keyword from spark dependencies
and also work if i use 3.0 version of scalatest but i need to use 2.0 version only
can someone help how could i resolve this issue?

Error reason: "scalatest" version "2.0" absent in Maven repository:
http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.scalatest%22%20AND%20a%3A%22scalatest_2.11%22
Please try existed, for example "2.2.0".
Guess, keyword "provided" is not related to error.

Related

Scala sbt library dependency - module not found error

I am trying to add a dependency to json4, but I get a module not found error. I am using scala-version 2.12.4 and sbt-version 1.1.1. My other dependency additions seem to add in a normal way.
Here is my code in build.sbt:
scalaVersion := "2.12.4"
libraryDependencies += "io.spray" %% "spray-json" % "1.3.4"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.4" % Test
libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.13.4" % Test
libraryDependencies += "org.json4s" %% "json4s-native" % "3.3.0"
This is the error message that I get:
[warn] module not found: org.json4s#json4s-native_2.12;3.3.0
[warn] ==== local: tried
[warn] /Users/*****/.ivy2/local/org.json4s/json4s-native_2.12/3.3.0/ivys/ivy.xml
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/org/json4s/json4s-native_2.12/3.3.0/ json4s-native_2.12-3.3.0.pom
[warn] ==== local-preloaded-ivy: tried
[warn] /Users/*****/.sbt/preloaded/org.json4s/json4s-native_2.12/3.3.0/ivys/ivy.xml
[warn] ==== local-preloaded: tried
[warn] file:////Users/*****/.sbt/preloaded/org/json4s/json4s-native_2.12/3.3.0/ json4s-native_2.12-3.3.0.pom
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.json4s#json4s-native_2.12;3.3.0: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
Help appreciated, thanks!
You need to use a newer version of this library.
Try this:
libraryDependencies += "org.json4s" %% "json4s-native" % "3.6.0-M3"
or some earlier version but not 3.3.0
Link to versions:
http://search.maven.org/#search%7Cga%7C2%7Cg%3A%22org.json4s%22
Edit: This problem is with compatibility. You use a new version of Scala and sbt. Previous version of this library are not compatible with this Scala version or sbt version.

Unable to resolve org.scalatest#scalatest;3.0.1: not found dependency issue

Newbie in scala here, going through a scala tutorial.
I am trying to use scalatest as mentioned in the tutorial but getting this error:
[error] (*:update) sbt.ResolveException: unresolved dependency: org.scalatest#scalatest;3.0.1: not found
> scalaVersion
[info] 2.10.6
My build.sbt file looks like this:
name := "tasky"
version := "0.1.0"
libraryDependencies += "org.scalactic" %% "scalactic" % "3.0.1"
libraryDependencies += "org.scalatest" % "scalatest" % "3.0.1" % "test"
Also as mentioned here, I have created the global.sbt and plugins.sbt file at the respective locations with the required details. But, I am still getting the error:
[info] Updating {file:/home/tushar/lsbt/tasky/}tasky...
[info] Resolving org.scalatest#scalatest;3.0.1 ...
[warn] module not found: org.scalatest#scalatest;3.0.1
[warn] ==== local: tried
[warn] /home/tushar/.ivy2/local/org.scalatest/scalatest/3.0.1/ivys/ivy.xml
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/org/scalatest/scalatest/3.0.1/scalatest-3.0.1.pom
[warn] ==== local-preloaded-ivy: tried
[warn] /home/tushar/.sbt/preloaded/org.scalatest/scalatest/3.0.1/ivys/ivy.xml
[warn] ==== local-preloaded: tried
[warn] file:////home/tushar/.sbt/preloaded/org/scalatest/scalatest/3.0.1/scalatest-3.0.1.pom
[warn] ==== Artima Maven Repository: tried
[warn] http://repo.artima.com/releases/org/scalatest/scalatest/3.0.1/scalatest-3.0.1.pom
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.scalatest#scalatest;3.0.1: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Unresolved dependencies path:
[warn] org.scalatest:scalatest:3.0.1 (/home/tushar/lsbt/tasky/built.sbt#L4-5)
[warn] +- default:tasky_2.10:0.1.0
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: org.scalatest#scalatest;3.0.1: not found
Any pointers to resolve this issue?
you should use %% instead of a single % as shown below. the %% changes the artifact from scalatest to scalatest_2.10 since the version of scala used in the project is 2.10.
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test"
You can either use %% or specify the artifact_id explicitly as below
libraryDependencies += "org.scalatest" % "scalatest_2.10" % "3.0.1" % "test"
the former approach is recommended over the later.
Explanation
Scala's minor version's are not backward compatible. so a library compiled with 2.10 version cannot be used in a project using scala 2.11. So a library has to be published by compiling it for each versions separately (2.10, 2.11 and 2.12 for eg).
thus all Scala artifacts are published with scala version suffixed at the end. Thus scalatest has a artifact scalatest_2.10,scalatest_2.11 and scalatest_2.12.
In order to make it easier to select the right version of the artifact in your SBT build depending on your scala version , SBT provides a convient symbol %% that will change the artifact id by appending the scala version for you. Thus if "org.scalatest" %% "scalatest" % "3.0.1" would translate to org.scalatest#scalatest_2.10;3.0.1 on your build dynamically.
If you are using maven repository then it should be
libraryDependencies += "org.scalatest" % "scalatest_2.11" % "3.0.1"
And your scalactic should be
libraryDependencies += "org.scalactic" % "scalactic_2.11" % "3.0.1"

How to set up blueeyes project in SBT?

I'm having trouble setting up this project using SBT.
It does not resolve blueeyes dependency when I type sbt run:
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.reportgrid#blueeyes_2.9.1.RC1;0.4.19: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Unresolved dependencies path:
[warn] com.reportgrid:blueeyes_2.9.1.RC1:0.4.19 (.../blueeyes-example/build.sbt#L19-22)
[warn] +- com.foo:blueeyes-test-api_2.9.1.RC1:0.1.0
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: com.reportgrid#blueeyes_2.9.1.RC1;0.4.19: not found
The BlueEyes project on Github seems abandoned but I hope there's still someone who can help me with this!
Form the documentation of the blueeyes repository, the dependencies should be declares like this:
resolvers ++= Seq(
"Sonatype" at "http://oss.sonatype.org/content/repositories/public",
"Typesafe" at "http://repo.typesafe.com/typesafe/releases/"
)
libraryDependencies ++= Seq(
"com.github.jdegoes" %% "blueeyes-core" % "0.6.0",
"com.github.jdegoes" %% "blueeyes-mongo" % "0.6.0",
"com.github.jdegoes" %% "blueeyes-json" % "0.6.0",
"ch.qos.logback" % "logback-classic" % "1.0.0" % "runtime"
)
your library dependencies look a bit different:
libraryDependencies ++= Seq(
"com.reportgrid" % "blueeyes_2.9.1.RC1" % "0.4.19" % "compile"
)
UPDATE:
And scala version needs to be
scalaVersion := "2.9.1"
instead of
scalaVersion := "2.9.1.RC1"

Scala / SBT - dependency not resolved on PaaS (cloudControl & heroku)

I have a simple Scala application built using spray.io. I am using Scala 2.11.2 and SBT 0.13.0. All of my dependencies are listed here:
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.3.6",
"com.typesafe.akka" %% "akka-slf4j" % "2.3.6",
"io.spray" % "spray-can_2.11" % "1.3.2",
"io.spray" % "spray-routing_2.11" % "1.3.2",
"io.spray" % "spray-json_2.11" % "1.3.1"
)
libraryDependencies += "org.mongodb" %% "casbah" % "2.7.2"
libraryDependencies += "com.stormpath.sdk" % "stormpath-sdk-api" % "1.0.RC4.2"
libraryDependencies += "com.stormpath.sdk" % "stormpath-sdk-httpclient" % "1.0.RC4.2"
While building and running it locally everything is fine but when i try to push / deploy it to PaaS platforms like cloudControl or heroku i am getting below dependency issue:
[info] Resolving org.apache.httpcomponents#httpclient;${httpclient.version} ...
[warn] module not found: org.apache.httpcomponents#httpclient;${httpclient.version}
[warn] ==== local: tried
[warn] /tmp/scala_buildpack_build_dir/.sbt_home/.ivy2/local/org.apache.httpcomponents/httpclient/${httpclient.version}/ivys/ivy.xml
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/org/apache/httpcomponents/httpclient/${httpclient.version}/httpclient-${httpclient.version}.pom
[warn] ==== spray repo: tried
[warn] http://repo.spray.io/org/apache/httpcomponents/httpclient/${httpclient.version}/httpclient-${httpclient.version}.pom
[warn] ==== spray nightlies: tried
[warn] http://nightlies.spray.io/org/apache/httpcomponents/httpclient/${httpclient.version}/httpclient-${httpclient.version}.pom
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/org/apache/httpcomponents/httpclient/${httpclient.version}/httpclient-${httpclient.version}.pom
...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.apache.httpcomponents#httpclient;${httpclient.version}: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: FAILED DOWNLOADS ::
[warn] :: ^ see resolution messages for details ^ ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.stormpath.sdk#stormpath-sdk-api;1.0.RC4.2!stormpath-sdk-api.jar
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
sbt.ResolveException: unresolved dependency: org.apache.httpcomponents#httpclient;${httpclient.version}: not found
...
[error] (*:update) sbt.ResolveException: unresolved dependency: org.apache.httpcomponents#httpclient;${httpclient.version}: not found
[error] download failed: com.stormpath.sdk#stormpath-sdk-api;1.0.RC4.2!stormpath-sdk-api.jar
[error] Total time: 59 s, completed May 4, 2015 1:05:37 PM
Inspecting my dependencies using sbt-dependency-graph shows me that not resolved org.apache.httpcomponents:httpclient is a nested dependency of com.stormpath.sdk:stormpath-sdk-httpclient:1.0.RC4.2.
For some reason variable ${httpclient.version} is not resolved during built - but that is all I can figure it out here. Please help!!!
I am not sure what is going on. But excluding the transitive dependency and adding it to SBT explicitily seems to fix the problem, at least the unresolved dependency problem:
libraryDependencies += "com.stormpath.sdk" % "stormpath-sdk-httpclient" % "1.0.RC4.2" exclude("org.apache.httpcomponents","httpclient")
libraryDependencies += "org.apache.httpcomponents" % "httpclient" % "4.2.2"
But keep in mind that we don't really know which version of apache's httpclient stormpath-sdk-httpclient used in its compilation, so you might run into runtime classpath/linking related exceptions. If that happens I recommend asking the developers of stormpath-sdk-httpclient.
EDIT:
you can see the version they used at:
https://github.com/stormpath/stormpath-sdk-java/blob/master/pom.xml#L98

UNRESOLVED DEPENDENCIES error while trying to create jar

I'm trying to build a Scala jar file to run it in spark.
I'm following this tutorial.
when trying to build jar file using sbt as here, i'm facing with following error
[info] Resolving org.apache.spark#spark-core_2.10.4;1.0.2 ...
[warn] module not found: org.apache.spark#spark-core_2.10.4;1.0.2
[warn] ==== local: tried
[warn] /home/hduser/.ivy2/local/org.apache.spark/spark-core_2.10.4/1.0.2/ivys/ivy.xml
[warn] ==== Akka Repository: tried
[warn] http://repo.akka.io/releases/org/apache/spark/spark-core_2.10.4/1.0.2/spark-core_2.10.4-1.0.2.pom
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/org/apache/spark/spark-core_2.10.4/1.0.2/spark-core_2.10.4-1.0.2.pom
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.apache.spark#spark-core_2.10.4;1.0.2: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[error] {file:/home/prithvi/scala/asd/}default-d57abf/*:update: sbt.ResolveException: unresolved dependency: org.apache.spark#spark-core_2.10.4;1.0.2: not found
[error] Total time: 2 s, completed 13 Aug, 2014 5:24:24 PM
what's the issue and how to solve it.
Dependency issue has been resolved. Thank you "om-nom-nom"but new error arised
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: FAILED DOWNLOADS ::
[warn] :: ^ see resolution messages for details ^ ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.eclipse.jetty.orbit#javax.transaction;1.1.1.v201105210645!javax.transaction.orbit
[warn] :: org.eclipse.jetty.orbit#javax.servlet;3.0.0.v201112011016!javax.servlet.orbit
[warn] :: org.eclipse.jetty.orbit#javax.mail.glassfish;1.4.1.v201005082020!javax.mail.glassfish.orbit
[warn] :: org.eclipse.jetty.orbit#javax.activation;1.1.0.v201105071233!javax.activation.orbit
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[error] {file:/home/prithvi/scala/asd/}default-c011e4/*:update: sbt.ResolveException: download failed: org.eclipse.jetty.orbit#javax.transaction;1.1.1.v201105210645!javax.transaction.orbit
[error] download failed: org.eclipse.jetty.orbit#javax.servlet;3.0.0.v201112011016!javax.servlet.orbit
[error] download failed: org.eclipse.jetty.orbit#javax.mail.glassfish;1.4.1.v201005082020!javax.mail.glassfish.orbit
[error] download failed: org.eclipse.jetty.orbit#javax.activation;1.1.0.v201105071233!javax.activation.orbit
[error] Total time: 855 s, completed 14 Aug, 2014 12:28:33 PM
You have your dependency defined as
"org.apache.spark" %% "spark-core" % "1.0.2"
That %% instructs sbt to substitute current scala version to artifact name. Apparently, spark was build for the whole family of 2.10 scala, without specific jars for 2.10.1, 2.10.2 ...
So all you have to do is to redefine it as:
"org.apache.spark" % "spark-core_2.10" % "1.0.2"
I had the same issue.
Looks like that some bugs are in different versions/compilations/etc.
For me the following build.sbt worked fine
name := "My Project"
version := "1.0"
scalaVersion := "2.11.8"
libraryDependencies += "org.apache.spark" %% "spark-sql" % "2.3.2"
Hope it helps
spark-core_2.10.4;1.0.2 means that it is build on top of scala 2.10 vesion.
so you have to specified this scalaVersion := "2.10.4" in your build file.
Please check your .sbt file and change accordingly.
libraryDependencies ++= Seq(
"org.apache.spark" %% "spark-core" % "1.1.0",
"org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016",
"org.eclipse.jetty.orbit" % "javax.transaction" % "1.1.1.v201105210645",
"org.eclipse.jetty.orbit" % "javax.mail.glassfish" % "1.4.1.v201005082020"
)
How can you change the current dependencies? I mean, when you type sbt package for a build file like:
name := "Simple Project"
version := "1.0"
scalaVersion := "2.10.4"
libraryDependencies += "org.apache.spark" %% "spark-core" % "1.2.0"
SBT will start resolving and downloading all kinds of dependencies. But if you see that it is failing on a dependency that is no longer inthe maven repo, what to do? Where can you change the dpencies it tries.
#OP: The problem is that your SBT is outdated. If you downloaded it using apt, you can use apt to remove it as well. In any case, download the latest .tgz (not the .deb) and simply unpack it, after that add the /sbt/bin/ folder to your .bashrc I noticed that older SBT's (the .deb and apt-get versions) work with older scala versions. You either need to manually add or change the dependencies that the older SBT is trying to find or simply change to the latest (not sooo)SBT.