I'm following a tutorial to create a scala web app with Heroku here: https://devcenter.heroku.com/articles/scala
I've copied there example exactly, but when I run
sbt clean compile stage
It fails to compile because of these errors:
[error] /home/ajcrites/dev/dyl/src/main/scala/Web.scala:1: object jboss is not a member of package org
[error] import org.jboss.netty.handler.codec.http.{HttpRequest, HttpResponse}
[error] ^
[error] /home/ajcrites/dev/dyl/src/main/scala/Web.scala:2: object twitter is not a member of package com
[error] import com.twitter.finagle.builder.ServerBuilder
[error] ^
[error] /home/ajcrites/dev/dyl/src/main/scala/Web.scala:3: object twitter is not a member of package com
[error] import com.twitter.finagle.http.{Http, Response}
[error] ^
[error] /home/ajcrites/dev/dyl/src/main/scala/Web.scala:4: object twitter is not a member of package com
[error] import com.twitter.finagle.Service
[error] ^
[error] /home/ajcrites/dev/dyl/src/main/scala/Web.scala:5: object twitter is not a member of package com
[error] import com.twitter.util.Future
[error] ^
[error] 5 errors found
Basically, I think it has to do with finagle not being available or not in the packages I have or something. However, I have no idea how to install finagle and there are neither instructions in the tutorial above nor at https://github.com/twitter/finagle
What can I do to get this to compile?
If will depend on the version of Scala and Finagle you want to use, but to add Finagle to the project, just add the following to build.sbt
libraryDependencies += "com.twitter" % "finagle-core_2.9.1" % "1.11.0" exclude("org.apache.thrift", "libthrift")
libraryDependencies += "com.twitter" % "finagle-http_2.9.1" % "1.11.0"
libraryDependencies += "com.twitter" % "finagle-serversets_2.9.1" % "1.11.0" excludeAll(
ExclusionRule(organization = "com.sun.jdmk"),
ExclusionRule(organization = "com.sun.jmx"),
ExclusionRule(organization = "javax.jms")
)
This example is about 3 months old, so I'm sure you can get a newer version of Finagle.
I tried the code and it worked for me. Perhaps see if the source on GitHub works: https://github.com/heroku/devcenter-scala
Related
I installed sbt-1.3.4.msi and when trying to build a sample SparkPi.scala app, I'm getting the following error:
C:\myapps\sbt\sparksample>sbt
[info] Loading project definition from C:\myapps\sbt\sparksample\project
[info] Compiling 1 Scala source to C:\myapps\sbt\sparksample\project\target\scala-2.12\sbt-1.0\classes ...
[error] C:\myapps\sbt\sparksample\project\src\main\scala\SparkPi.scala:3:19: object spark is not a member of package org.apache
[error] import org.apache.spark._
[error] ^
[error] C:\myapps\sbt\sparksample\project\src\main\scala\SparkPi.scala:8:20: not found: type SparkConf
[error] val conf = new SparkConf().setAppName("Spark Pi")
[error] ^
[error] C:\myapps\sbt\sparksample\project\src\main\scala\SparkPi.scala:9:21: not found: type SparkContext
[error] val spark = new SparkContext(conf)
[error] ^
[error] three errors found
[error] (Compile / compileIncremental) Compilation failed
The SparkPi.scala file is in C:\myapps\sbt\sparksample\project\src\main\scala (as shown in the error messages above).
What am I missing here?
The C:\myapps\sbt\sparksample\sparksample.sbt file is as follows:
name := "Spark Sample"
version := "1.0"
scalaVersion := "2.12.10"
libraryDependencies += "org.apache.spark" %% "spark-core" % "3.0.0"
C:\myapps\sbt\sparksample\project\src\main\scala directory has SparkPi.scala file
That's the problem. You've got the Scala file(s) under project directory that's owned by sbt itself (not your sbt-managed Scala project).
Move the SparkPi.scala and other Scala files to C:\myapps\sbt\sparksample\src\main\scala.
I am running into an issue when I run "sbt package" on a scala program. Here are the imports that I have in my scala program
import java.sql.{Connecion,DriverManager,ResultSet}
when I run sbt package, I get the below errors.
[error] /home/SriniNN/scala_cd/ReadDJDBC/src/main/scala/ReadDJDBC.scala:8: object Connecion is not a member of package java.sql
[error] import java.sql.{Connecion,DriverManager,ResultSet}
[error] ^
[error] /home/SriniNN/scala_cd/ReadDJDBC/src/main/scala/ReadDJDBC.scala:26: value getConnecion is not a member of object java.sql.DriverManager
[error] val jdbcRDD = new JdbcRDD(sc, () => DriverManager.getConnecion(url,username,password),
This is what I have in my build.sbt
name:= "ReadJDBC"
version:= "1.0"
scalaVersion:= "2.11.8"
libraryDependencies += "org.apache.spark" % "spark-core_2.11" % "1.6.2"
Can you please help me resolve this issue?
You are just mis-spelling Connection. Note the t between the c and i. If you fix that typo then it should work
When running play compile, I get a compile-time error.
[error] test.scala:14: object BOMInputStream is not a member of package org.ap
ache.commons.io.input
[error] import org.apache.commons.io.input.BOMInputStream
[error] ^
[error] test.scala:80: not found: type BOMInputStream
[error] val bomIn = new BOMInputStream(fileInpStream, false)
[error] ^
[error] two errors found
However, I successfully ran a scalatest test using the BOMInputStream in the same play project within the /test directory.
When I comment out the offending lines in the above compile-time error, the test succeeds.
Note that I've updated my /project/Build.scala appropriately:
"org.apache.commons" % "commons-io" % "1.3.2"
After deleting a JAR, which contained the BOMInputStream class, from my PLAY-PROJECT/lib/ directory, I was able to compile.
I have the following spec:
import org.specs2.mock.Mockito
import org.specs2.mutable.Specification
class LinkUserServiceSpec extends Specification with Mockito {
val linkUserService = mock[LinkUserService]
"The 'LinkUserService' isUserLinked method" should {
"return false when a previously unlinked userId is passed in for a given service" in {
linkUserService.isUserLinked("nobody", "YT") returns false
linkUserService.isUserLinked("nobody", "YT") must beFalse
}
}
}
And the following dependency in my build.sbt:
"org.specs2" %% "specs2" % "2.2" % "test"
However I get this error when I type test into the sbt console:
[error] bad symbolic reference. A signature in MocksCreation.class refers to type MockSettings
[error] in package org.mockito 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 MocksCreation.class.
[error] bad symbolic reference. A signature in MockitoStubs.class refers to term stubbing
[error] in package org.mockito 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 MockitoStubs.class.
[error] two errors found
[error] (test:compile) Compilation failed
[error] Total time: 3 s, completed Sep 12, 2013 3:23:41 PM
Anyone know what this could be?
Apparently if you want to use Mockito with Specs2 you have to provide the dependency yourself, I added the following to my build.sbt and things started working:
"org.mockito" % "mockito-all" % "1.9.5"
scalac is successed to compile this code.
import ch.epfl.lamp.fjbg._
But sbt(0.11.2) is failed to compile it.
[error] genbytecode.scala:2: not found: object ch
[error] import ch.epfl.lamp.fjbg._
[error] ^
[error] one error found
Why and how can I fix this?
The OP posted a comment:
I create build.sbt and write libraryDependencies += "org.scala-lang" % "scala-compiler" % "2.9.1" work it! thank you.