SBT - missing dependency - scala

Well, my collaborator run code under build.sbt shown below without any problems while I get:
[error] /.../GameMap.scala:91: value revalidate is not a member of javax.swing.JFrame
[error] frame.revalidate()
[error] ^
[error] /.../GameMap.scala:92: value revalidate is not a member of java.awt.Container
[error] frame.getContentPane.revalidate()
[error] ^
I suspect, something is missing in build.sbt:
scalaVersion := "2.10.4"
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
// scalacOptions ++= Seq("-feature")
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.3.8",
"com.typesafe.akka" %% "akka-cluster" % "2.3.8",
"org.scala-lang" % "scala-swing" % "2.10.4"
)
What is it ?

My guess is that your running Java 6 and your collaborator is running Java 7
This is the Container documentation for java 6, which does not list a revalidate method inherited from Component.
And here is the java 7 documentation, which DOES list a revalidate method being inherited from Component
*The same can be stated for swing

Related

Scala SBT is not able to download dependencies

I am new to scala and Akka. I have created a new project and below is my build.sbt file.
name := "akka_essentials"
version := "0.1"
scalaVersion := "2.13.4"
val akkaVersion = "2.5.13"
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % akkaVersion,
"com.typesafe.akka" %% "akka-testkit" % akkaVersion,
"com.scalatest" %% "scalatest" % "3.0.5"
)
The sbt tool is not able to download dependencies. The error log is as below:
[error] stack trace is suppressed; run 'last update' for the full output
[error] (update) sbt.librarymanagement.ResolveException: Error downloading com.typesafe.akka:akka-testkit_2.13:2.5.13
[error] Not found
[error] Not found
[error] not found: C:\Users\Anand\.ivy2\local\com.typesafe.akka\akka-testkit_2.13\2.5.13\ivys\ivy.xml
[error] not found: https://repo1.maven.org/maven2/com/typesafe/akka/akka-testkit_2.13/2.5.13/akka-testkit_2.13-2.5.13.pom
[error] Error downloading com.scalatest:scalatest_2.13:3.0.5
[error] Not found
[error] Not found
[error] not found: C:\Users\Anand\.ivy2\local\com.scalatest\scalatest_2.13\3.0.5\ivys\ivy.xml
[error] not found: https://repo1.maven.org/maven2/com/scalatest/scalatest_2.13/3.0.5/scalatest_2.13-3.0.5.pom
[error] Error downloading com.typesafe.akka:akka-actor_2.13:2.5.13
[error] Not found
[error] Not found
[error] not found: C:\Users\Anand\.ivy2\local\com.typesafe.akka\akka-actor_2.13\2.5.13\ivys\ivy.xml
[error] not found: https://repo1.maven.org/maven2/com/typesafe/akka/akka-actor_2.13/2.5.13/akka-actor_2.13-2.5.13.pom
I am very new to scala. I have not defined anything like ivy.xml. I am from java background and generally use gradle.
Please advise to resolve this.
Akka 2.5.13 has not been cross published for Scala 2.13 as you can check on Maven.
The earliest version supporting 2.13 (release, not milestone or RC) is 2.5.23. You can see the version matrix for Actors here.
So you need to use newer Akka or older Scala.
With Scalatest you used wrong organization. It's "org.scalatest" not "com.scalatest".
If you have doubts about dependency resoultion check Maven first.
I did the following changes to make it work:
name := "project"
version := "0.1"
scalaVersion := "2.12.7"
val akkaVersion = "2.5.13"
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % akkaVersion,
"com.typesafe.akka" %% "akka-testkit" % akkaVersion
// "com.scalatest" %% "scalatest" % "3.0.5"
)

scala error: bad symbolic reference

I was using sbt to compile a scala code, and got the following error message
[error] /user/xyin/Projects/measurement_wspark/src/main/scala/json2csv.scala:41: bad symbolic reference. A signature in DefaultReads.class refers to term time
[error] in package java which is not available.
[error] It may be completely missing from the current classpath, or the version on
[error] the classpath might be incompatible with the version used when compiling DefaultReads.class.
[error] val ts = (json \ "RequestTimestamp").validate[String]
[error] ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
I was using the play json library to parse json files in my main class. And the content of the build.sbt file is like the following:
name := "json_parser"
version := "1.0"
scalaVersion := "2.10.1"
libraryDependencies += "org.apache.spark" %% "spark-core" % "1.6.1"
resolvers += "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/"
libraryDependencies += "com.typesafe.play" %% "play-json" % "2.4.8"
I am totally new to scala and the play framework. Does anyone has any clue about this problem? Thanks!

How do I add scalatest dependency to an existing scala/lift project?

I am trying to add scalatest support to an existing scala and lift app
I add a dependency to build.sbt as per the following excerpt
resolvers ++= Seq(
"Java.net Maven2 Repository" at "http://download.java.net/maven/2/",
"Sonatype scala-tools repo" at "https://oss.sonatype.org/content/groups/scala-tools/",
"Sonatype scala-tools releases" at "https://oss.sonatype.org/content/repositories/releases",
"Sonatype scala-tools snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
)
libraryDependencies ++= {
val liftVersion = "2.6"
Seq(
"net.liftweb" %% "lift-webkit" % liftVersion % "compile",
"net.liftweb" %% "lift-mapper" % liftVersion % "compile",
"junit" % "junit" % "4.7" % "test",
"org.scalatest" % "scalatest_2.11" % "2.2.4" % "test"
)
}
and then I create a test class
class GeoUtilsTest extends org.scalatest.FlatSpec {
}
when I do sbt compile or sbt test I get the following error
[error] C:\Users\Andrew Bucknell\Documents\project-alpha\src\main\scala\com\myapp\api\utilities\GeoUtils$Test.scala:6: object scalatest is not a member of package org
[error] class GeoUtilsTest extends org.scalatest.FlatSpec {
[error] ^
The problem here is that scalatest cannot be found. I am not sure why adding the dependency to the build.sbt isnt enough to bring it in and add it to the project - its always been enough before. sbt update finds and downloads the dependency. Any thoughts?
It seems that you have specified the dependency of scalatest to be visible only to test package and you code doesn't seems to be located there. So, either change the dependency into build.sbt from test to compile, or better move the testing code into test package.

How to add jdbc dependency to Play project?

I'm using play 2.2.2.
I'd like to enable jdbc library in a Play/Scala project as mentioned in Accessing an SQL database.
Here's my rootproject/project/plugins.sbt:
libraryDependencies ++= Seq(
jdbc
"com.google.zxing" % "core" % "2.0",
"mysql" % "mysql-connector-java" % "5.1.27",
"com.typesafe.slick" %% "slick" % "2.1.0",
"org.slf4j" % "slf4j-nop" % "1.6.4"
)
While compiling the project, I get following jdbc not found error,
$ /usr/local/play-2.2.2/play compile
/packup/smartad-core/project/plugins.sbt:8: error: not found: value jdbc
jdbc
^
[error] Type error in expression
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? q
My rootproject/build.sbt simply is
import play.Project._
name := "smartad-backend"
version := "1.0"
playScalaSettings
References
https://www.playframework.com/documentation/2.3.x/ScalaAnorm
You should combine both of those blocks into your build.sbt file. plugins.sbt is for adding sbt plugins, such as the play sbt plugin. But that's about it.
import play.Project._
name := "smartad-backend"
version := "1.0"
playScalaSettings
libraryDependencies ++= Seq(
jdbc,
...
)

Play framework compilation issues with dependencies

I'm having issues with running a simple scala play app with a few dependencies. The below is happening when trying to run my app.
[error] /Users/roland/play-scala/app/domain/UserModule.scala:2:
object softwaremill is not a member of package com
[error] import com.softwaremill.macwire.MacwireMacros.wire
UserModule:
package domain
import com.softwaremill.macwire.MacwireMacros.wire
trait UserModule {
lazy val userRepository = wire[UserRepository]
lazy val userService = wire[UserService]
}
and my build.sbt is
name := """play-scala"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.10.3"
resolvers += "Maven Central Server" at "http://repo1.maven.org/maven2"
resolvers += "Neo4j Scala Repo" at "http://m2.neo4j.org/content/repositories/releases"
resolvers += "Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
libraryDependencies ++= Seq(
jdbc,
anorm,
cache,
ws,
"org.webjars" % "coffee-script-node" % "1.7.1",
"net.liftweb" %% "lift-json" % "3.0-SNAPSHOT",
"eu.fakod" %% "neo4j-scala" % "0.3.1-SNAPSHOT",
"com.softwaremill.macwire" %% "macros" % "0.7.3",
"com.softwaremill.macwire" %% "runtime" % "0.7.3"
)
It seems to be totally fine when looking at it in intellij idea and looking in my ivy cache I have the dependencies there but the application when it runs through the play console seems to be very unhappy. Sorry for the lack of info but im quite new to scala and play so been struggling all day with this issue.
Indeed the maven repo is named macros_2.10 but there is scalaVersion := "2.10.3" in build.sbt
Try to remove this line.