akka创建actor时报错:IllegalArgumentException: no matching constructor found on class $iwC$$iwC$$iwC$$iwC$
在spark-shell中输入范例中的代码:
import akka.actor.Actor
import akka.actor.Props
import akka.event.Logging class MyActor extends Actor {
val log = Logging(context.system, this)
def receive = {
case "test" ⇒ log.info("received test")
case _ ⇒ log.info("received unknown message")
}
} val system = ActorSystem("MySystem")
val myActor = system.actorOf(Props[MyActor], name = "myactor")
结果总是遇到如下错误:
scala> val myActor = system.actorOf(Props[MyActor], name = "myactor")
java.lang.IllegalArgumentException: no matching constructor found on class $iwC$$iwC$$iwC$$iwC$MyActor for arguments []
at akka.util.Reflect$.error$1(Reflect.scala:81)
at akka.util.Reflect$.findConstructor(Reflect.scala:93)
at akka.actor.Props.constructor(Props.scala:194)
at akka.actor.Props.<init>(Props.scala:213)
at akka.actor.Props$.apply(Props.scala:69)
at $iwC$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC.<init>(<console>:24)
百思不得其解!最后终于找到了原因:不能采用内嵌类作为actor类!!!!spark-shell里面的类会被认为是内嵌类,为了避免以上错误,需要单独写类文件。
stackoverflow里面是这么解释的:
Take this example:
class A{
class B{}
}
I can do new A, but new B will return an error. I have to do:
val a = new A
val b = new a.B
That's why akka failed to create this actor.
随机推荐
- Linode各机房在中国访问速度性能测试
最近因为google的各种被X的原因,想自己弄个VPS玩玩,比来比去都推荐linode. 因为各种性能测试工具都不靠谱,还是自己机器来的直接,虽然笨拙但是真实可信. 从测试结果上看,明显东京机房的速度 ...
- 宿舍局域网与Internet连接
写在前面的话 一般情况下,大多数组建了校园网的学校都为学生宿舍提供了连接Internet接口,所以只需要通过网线将宿舍网的集线器与校园网提供的接口进行连接即可接入Internet.宿舍网接入Inter ...
- 教程-Delphi各版本与工具下载地址
1.Delphi 7.0 下载地址:http://www.skycn.com/soft/2121.html 注册码:(正在用的没有问题)V8S3-KM82KQ-XN8JQK-EPS33EA-GZK汉化 ...
- python 类和实例
面向对象最重要的概念就是类(Class)和实例(Instance),必须牢记类是抽象的模板,比如Student类,而实例是根据类创建出来的一个个具体的“对象”,每个对象都拥有相同的方法,但各自的数据可 ...
- IOS获取摄像和本地中的资源
上传文件时,我们都的从本地中选择或用相机来拍摄得到文件. 一个上传按钮,单击事件 1 -(IBAction)btnClick{ 2 UIActionSheet* actionSheet = [[UIA ...
- java泛型 8 泛型的内部原理:类型擦除以及类型擦除带来的问题
参考:java核心技术 一.Java泛型的实现方法:类型擦除 前面已经说了,Java的泛型是伪泛型.为什么说Java的泛型是伪泛型呢?因为,在编译期间,所有的泛型信息都会被擦除掉.正确理解泛型概念的首 ...
- 解决 mac ssh空闲 连接断开问题
想必大家都知道,用终端 ssh 连接服务器,如果长时间没有操作,会被断开连接. 要用的话又得重新登录,这非常不方便,也影响开发效率.那针对这种情况,有没有解决方法呢? 答案是肯定的.理论上,有两种方案 ...
- Android开发之有效获取状态栏(StatusBar)高度
获取状态栏高度 一.传统方式:有时获取为0,解决方法看 二 1 2 3 4 代码 Rect frame = new Rect(); getWindow().getDecorView().getWin ...
- HDU 5477 A Sweet Journey 水题
A Sweet Journey Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pi ...
- ZOJ 3827 Information Entropy 水题
Information Entropy Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.zju.edu.cn/onlinejudge/sh ...