Create an actor

Viewed 3071

This is probably an extremely simple error but I can't get it to work properly. I am using akka 2.2.3 to create an actor based application in scala.

The simplified setup is the following:

object Main {
  def main(args: Array[String]) = {
    val system = ActorSystem("Test")
    val discoverer = system.actorOf(Props[Discoverer], "discoverer")

    implicit val timeout = Timeout(5.seconds)

    val not = discoverer ? Messages.Find(something)

    not.onComplete {
      case Success(va) => println(va)
      case Failure(err) => println(err)
    }
    ...
  }
}

And the main actor

class Discoverer extends Actor {
  override def preStart() = {
    val refresher = context.actorOf(Props[Refresher], "refresher")
    refresher ! Refresh
  }

  def receive = {
    case _ => sender ! Answer
  }
}

And the Refresher actor

 class Refresher extends Actor {
   ...
 }

What you should take away from this is that none of my actors has parameterized constructors.

However if I try to run my application it fails with

[ERROR] [12/09/2013 13:17:06.893] [Test-akka.actor.default-dispatcher-3] 
 [akka://Test/user/discoverer] no matching constructor found on 
  class Discoverer$Refresher for arguments []

What is my error here? Am I not supposed to create my actors with .actorOf(Props[Class], "actorname")?

2 Answers
Related