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.
Related
My play framework application is all of a sudden throwing the following errors during compilation:
[error] /Users/ihorton/Client Work/DPaaS/coursera-scala/cookbook/app/controllers/HomeController.scala:5:14: object inject is not a member of package javax
[error] import javax.inject._
[error] ^
[error] /Users/ihorton/Client Work/DPaaS/coursera-scala/cookbook/app/controllers/HomeController.scala:11:2: trait Singleton is abstract; cannot be instantiated
[error] #Singleton
[error] ^
[error] /Users/ihorton/Client Work/DPaaS/coursera-scala/cookbook/app/controllers/HomeController.scala:12:23: not found: type Inject
[error] class HomeController #Inject()(controllerComponents: ControllerComponents) extends AbstractController(controllerComponents) {
[error] ^
^
Here is my use of javax.inject, #Inject and #Singleton in code:
import javax.inject._
#Singleton
class RecipeController #Inject()(controllerComponents: ControllerComponents) extends AbstractController(controllerComponents) {
...
I've read through what looks to be the same issue here, but trying sbt reload prior to compile doesn't work for me.
What's puzzling, unless I'm misreading the Play Framework 2.8.x documentation, is that it seems like javax.inject should be packaged with Play out of the box. So I'm not sure why this object would be missing.
I'm using the following versions:
Play: 2.8.8
Scala: 2.13.6
JDK: 17.0.1
Here's my build.sbt file to which I've added javax.inject which doesn't seem to resolve the issue.
name := """cookbook"""
organization := "com.ian-horton"
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.13.6"
libraryDependencies ++= Seq(
guice,
"commons-io" % "commons-io" % "2.5",
"javax.inject" % "javax.inject" % "1",
"net.sourceforge.tess4j" % "tess4j" % "5.0.0",
"org.scalatestplus.play" %% "scalatestplus-play" % "5.0.0" % Test,
"org.specs2" %% "specs2-core" % "4.13.0" % Test)
Happy to provide additional detail if need be.
Thanks in advance!
Update
Finding this other Stack Overflow Question I followed the steps manually added the Maven dependency for Javax.Inject to my project in Intellij which fixed the problem.
I'm keeping this question open though in the hopes that someone can perhaps shed some light on why this dependency isn't pulled in with Play.
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
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!
I'm trying to execute JUnit test
sbt test
sbt clean test
Test fails with error :
[info] Updating {file:/D:/sbt_projects/hello-word-ec/}hello-word-ec...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Compiling 2 Scala sources to D:\sbt_projects\hello-word-ec\target\scala-2.10\test-classes...
[error] D:\sbt_projects\hello-word-ec\src\test\scala\Test1.scala:1: object junit is not a member of package org
[error] import org.junit.Test
[error] ^
[error] D:\sbt_projects\hello-word-ec\src\test\scala\Test1.scala:3: not found: type Test
[error] #Test
[error] ^
[error] D:\sbt_projects\hello-word-ec\src\test\scala\Test2.scala:1: object junit is not a member of package org
[error] import org.junit.Test
[error] ^
[error] D:\sbt_projects\hello-word-ec\src\test\scala\Test2.scala:2: object junit is not a member of package org
[error] import org.junit.BeforeClass
[error] ^
[error] D:\sbt_projects\hello-word-ec\src\test\scala\Test2.scala:6: not found: type BeforeClass
[error] #BeforeClass
[error] ^
[error] D:\sbt_projects\hello-word-ec\src\test\scala\Test2.scala:12: not found: type Test
[error] #Test
[error] ^
[error] 6 errors found
[error] (test:compileIncremental) Compilation failed
[error] Total time: 1 s, completed Jul 28, 2016 6:10:04 PM
My build.sbt file content
name := "sbt junit test project"
version := "1.0"
scalaVersion := "2.10.5"
libraryDependencies += "com.novocode" % "junit-interface" % "0.8" % "test->default"
libraryDependencies += "junit" % "junit" % "4.12" % Test
EclipseKeys.withSource := true
file %USERDIR%.sbt\0.13\plugins\build.sbt looks like
resolvers += Classpaths.typesafeResolver
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")
Put build.sbt in root project folder otherwise sbt clean cannot see the build.sbt and download dependencies . Originally build.sbt was located in <project root>\project\ folder
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