我尝试执行以下代码时出现序列化错误
public Result implements Serializable {
ArrayList<AvroGeneratedEntity> entities;
Map<Integer, String> stringMap;
}
public SomeBo {
public void aMethod () {
......
JavaRdd<Result> resultJavaRDD = rdd.map(f -> {
});
resultJavaRDD.repartition(1).collect(); // Error throws
......
}
}
根据错误消息,这是因为avrogeneratedentity不可序列化
Serialization stack:
- object not serializable (class: com.testing.AvroGeneratedEntity, value:
.....
- field (class: com.testing.AvroGeneratedEntity, name: entities, type: class java.util.ArrayList)
- object (class com.testing.AvroGeneratedEntity, com.testing.AvroGeneratedEntity@390fcb0c)
at org.apache.spark.serializer.SerializationDebugger$.improveException(SerializationDebugger.scala:40)
at org.apache.spark.serializer.JavaSerializationStream.writeObject(JavaSerializer.scala:47)
at org.apache.spark.serializer.SerializationStream.writeValue(Serializer.scala:147)
暂无答案!
目前还没有任何答案,快来回答吧!