theTuxRacer
theTuxRacer

Reputation: 13879

Error in scala + dispatch

I am trying to GET a response from an API, using scala and dispatch. However, I get this error, after building. I googled for a solution, and tried cleaning, and resarting eclipse, but the error wont go away. What seems to be the problem? I use eclipse Helios (ie 3.6) and Scala v2.8.1, with Scala IDE v1.0.0.201104170033, installed from the Eclipse market.

dispatch{dispatch.type}.Http{object dispatch.Http} of type object dispatch.Http does not take parameters

This is my code.

class getList {
  def main(args: Array[String]){
    Http("http://foo.com/" >>> System.out)
  }
}

What am I doing wrong?

Upvotes: 0

Views: 962

Answers (1)

Daniel C. Sobral
Daniel C. Sobral

Reputation: 297295

What libraries have you downloaded? Are you sure the dependencies are set correctly? I tried with dispatch_http, version 8.0 for Scala 2.8.1, and it worked.

What imports are you using? I used these imports to make it work:

import dispatch.Http
import dispatch.HandlerVerbs._

Finally... class getList??? I assume this is a result of cut&pasting from actual code, but you should strive to produce a compilable example of your problem. Scala doesn't run programs from class, only from object, and it follows Java style of having classes start with an uppercase letter.

Here's the minimal code I used with SBT to get a working example.

Initializing:

~/test$ sbt
Project does not exist, create new project? (y/N/s) y
Name: test
Organization: test
Version [1.0]: 
Scala version [2.7.7]: 2.8.1
sbt version [0.7.4]:

~/test$ cat project/build/TestProject.scala 
import sbt._

class TestProject(info: ProjectInfo) extends DefaultProject(info) {
  val dvers = "0.8.0"
  val http = "net.databinder" %% "dispatch-http" % dvers
}

~/test$ cat src/main/scala/GetList.scala 
import dispatch.Http
import dispatch.HandlerVerbs._

object GetList {
  def main(args: Array[String]){
    Http("http://foo.com/" >>> System.out)
  }
}

~/test# sbt update run

Upvotes: 2

Related Questions