试图在akka中创建一个actor并调用它的receive函数。我不断收到此错误。
[ERROR] [10/26/2013 18:53:29.313] [messagespreading-akka.actor.default-dispatcher-4] [akka://messagespreading/user/$a] error while processing Create(-1187846526)
70ec3d6a-184d-403c-8166-04aec76200c9akka.actor.ActorInitializationException: exception during creation
at akka.actor.ActorInitializationException$.apply(Actor.scala:169)
at akka.actor.ActorCell.create(ActorCell.scala:496)
at akka.actor.ActorCell.systemInvoke(ActorCell.scala:351)
at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:256)
at akka.dispatch.Mailbox.run(Mailbox.scala:211)
at akka.dispatch.ForkJoinExecutorConfigurator$MailboxExecutionTask.exec(AbstractDispatcher.scala:502)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: java.lang.IllegalArgumentException: n must be positive
at java.util.Random.nextInt(Random.java:250)
at scala.util.Random.nextInt(Random.scala:65)
at NetworkBuilder.<init>(pastry.scala:431)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:357)
at java.lang.Class.newInstance(Class.java:310)
at akka.util.Reflect$.instantiate(Reflect.scala:39)
at akka.actor.FromClassCreator.apply(Props.scala:187)
at akka.actor.FromClassCreator.apply(Props.scala:186)
at akka.actor.ActorCell.newActor(ActorCell.scala:461)
at akka.actor.ActorCell.create(ActorCell.scala:479)
... 8 more
创建和调用 ACTOR RECEIVE 的代码。
val system = ActorSystem("messagespreading")
var NetworkBuilderObj:ActorRef= system.actorOf(Props[NetworkBuilder])
NetworkBuilderObj ! test