I am trying to create an actor with untyped actor factory, compilation happens fine. But while running the application, I get the following error. Am I missing anything in configuration?
Java Code:
MyActor myactor = new MyActor(); //MyActor extends UnTypedActor
ActorSystem system = ActorSystem.create("mynamespace");
ActorRef actor = system.actorOf(new Props(new UntypedActorFactory() {
public UntypedActor create() {
return myactor;
}
}));
Error during runtime:
Caused by: akka.actor.ActorInitializationException: You cannot create an instance of [com.practice.MyActor] explicitly using the constructor (new). You have to use one of the factory methods to create a new actor. Either use: 'val actor = context.actorOf(Props[MyActor])'
(to create a supervised child actor from within an actor), or 'val actor = system.actorOf(Props(new MyActor(..)))' (to create a top level actor from the ActorSystem)