我正在尝试将一个对象发送给一个远程演员,但我遇到了这个异常:
ERROR akka.remote.EndpointWriter - Transient association error (association remains live)
java.io.NotSerializableException: scala.collection.immutable.MapLike$$anon$2
被序列化的对象是一个案例类:
case class LocationReport(idn: String, report: String, timestamp: Option[String], location: Attr, status: Attr, alarms: Attr, network: Attr, sensors: Attr) extends Message(idn) {
val ts = timestamp getOrElse location("fix_timestamp")
def json =
(report ->
("TIME" -> ts) ~
("location" -> location) ~
("alarms" -> alarms) ~
("network" -> network) ~
("sensors" -> ((status ++ sensors) + ("CUSTOMCLOCK" -> Report.decodeTimestamp(ts)))))
}
并且Attr
是类型重新定义:
type Attr = Map[String, String]
这个Message
类很简单:
abstract class Message(idn: String) {
def topic = idn
def json(): JValue
}
我想知道类型别名/重新定义是否混淆了序列化程序。我想我正在使用 ProtoBuf 序列化,但我确实在堆栈跟踪中看到JavaSerializer
了。
更多调试信息
我更新了一个 JavaSerializer 并单独序列化了每个 Maps。只有一个 ( alarms
) 无法序列化。这是他们每个人的 toString :
这个失败了:
alarms = Map(LOWBATTERY -> 1373623446000)
这些成功了:
location = Map(a_value -> 6, latitude -> 37.63473, p_value -> 4, longitude -> -97.41459, fix_timestamp -> 3F0AE7FF, status -> OK, fix_type -> MSBL, CUSTOMCLOCK -> 1373644159000)
network = Map(SID -> 1271, RSSI -> 85)
sensors = Map(HUMIDITY -> -999, PRESSURE -> -999, LIGHT -> -999 9:52 AM)
status = Map(TEMPERATURE_F -> 923, CYCLE -> 4, TEMPERATURE1_C -> 335, CAP_REMAINING -> 560, VOLTAGE -> 3691, CAP_FULL -> 3897)