ActorRef作为Akka中消息的一部分(java.io.NotSerializableException)

时间:2011-11-28 17:10:29

标签: scala akka

使用Akka 1.2(和1.3-RC1)我仍然在2010年11月的http://groups.google.com/group/akka-dev/browse_thread/thread/fe85adf5aeeec168

中遇到Viktor提到的同样问题

即尝试向远程actor发送本地actor引用会导致下面的异常。我想知道这是否是现在的预期,或者是否有一些Akka配置设置等。我遗漏了可以启用所需的巫毒魔法,以根据需要自动序列化演员引用?

谢谢, 太棒了,斯卡拉

[ERROR]   [11/28/11 11:55 AM] [akka:event-driven:dispatcher:global-32] [LocalActorRef] akka.actor.LocalActorRef
java.io.NotSerializableException: akka.actor.LocalActorRef
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
at akka.serialization.Serializer$Java$class.toBinary(Serializer.scala:60)
at akka.serialization.Serializer$Java$.toBinary(Serializer.scala:55)
at akka.remote.MessageSerializer$.serialize(MessageSerializer.scala:55)
at akka.serialization.RemoteActorSerialization$.createRemoteMessageProtocolBuilder(SerializationProtocol.scala:327)
at akka.remote.netty.RemoteClient.send(NettyRemoteSupport.scala:252)
at akka.remote.netty.NettyRemoteClientModule$$anonfun$send$1.apply(NettyRemoteSupport.scala:109)
at akka.remote.netty.NettyRemoteClientModule$$anonfun$send$1.apply(NettyRemoteSupport.scala:109)
at akka.remote.netty.NettyRemoteClientModule$class.withClientFor(NettyRemoteSupport.scala:134)
at akka.remote.netty.NettyRemoteSupport.withClientFor(NettyRemoteSupport.scala:647)
at akka.remote.netty.NettyRemoteClientModule$class.send(NettyRemoteSupport.scala:109)
at akka.remote.netty.NettyRemoteSupport.send(NettyRemoteSupport.scala:647)
at akka.actor.RemoteActorRef.postMessageToMailbox(ActorRef.scala:1246)
at akka.actor.ScalaActorRef$class.$bang(ActorRef.scala:1410)
at akka.actor.RemoteActorRef.$bang(ActorRef.scala:1219)

...

1 个答案:

答案 0 :(得分:3)

文档很精彩:http://akka.io/docs/akka/1.3-RC1/scala/serialization.html#id7

我还可以补充一点,这在2.0

中是完全透明的