开发者社区> 问答> 正文

flink 类型转换,scala 继承map接口后,报java.lang.ClassCastException

灰灰fly 2019-01-28 10:47:59 602

类型:
case class RIchMap(data:Map[String,Any] = Map()) extends Map[String, Any] with GenMap[String, Any] with Serializable

执行:stream.flatMapRichMap(TypeInformation.of(classOf[RichMap]))
传类型: fun: RichMap => TraversableOnce[RichMap]
总是报 :
java.lang.ClassCastException: scala.collection.immutable.Map$Map1 cannot be cast to com.haima.sage.bigdata.etl.common.model.RichMap

at com.haima.sage.bigdata.analyzer.streaming.source.AkkaSink.invoke(AkkaSink.scala:20)
at org.apache.flink.streaming.api.functions.sink.SinkFunction.invoke(SinkFunction.java:52)
at org.apache.flink.streaming.api.operators.StreamSink.processElement(StreamSink.java:56)
at org.apache.flink.streaming.runtime.tasks.OperatorChain$CopyingChainingOutput.pushToOperator(OperatorChain.java:579)
at org.apache.flink.streaming.runtime.tasks.OperatorChain$CopyingChainingOutput.collect(OperatorChain.java:554)
at org.apache.flink.streaming.runtime.tasks.OperatorChain$CopyingChainingOutput.collect(OperatorChain.java:534)
at org.apache.flink.streaming.api.operators.AbstractStreamOperator$CountingOutput.collect(AbstractStreamOperator.java:689)
at org.apache.flink.streaming.api.operators.AbstractStreamOperator$CountingOutput.collect(AbstractStreamOperator.java:667)
at org.apache.flink.streaming.api.operators.TimestampedCollector.collect(TimestampedCollector.java:51)
at org.apache.flink.streaming.api.scala.DataStream$$anon$6$$anonfun$flatMap$1.apply(DataStream.scala:663)
at org.apache.flink.streaming.api.scala.DataStream$$anon$6$$anonfun$flatMap$1.apply(DataStream.scala:663)
at scala.collection.immutable.List.foreach(List.scala:392)
at org.apache.flink.streaming.api.scala.DataStream$$anon$6.flatMap(DataStream.scala:663)
at org.apache.flink.streaming.api.operators.StreamFlatMap.processElement(StreamFlatMap.java:50)
at org.apache.flink.streaming.runtime.io.StreamInputProcessor.processInput(StreamInputProcessor.java:202)
at org.apache.flink.streaming.runtime.tasks.OneInputStreamTask.run(OneInputStreamTask.java:105)
at org.apache.flink.streaming.runtime.tasks.StreamTask.invoke(StreamTask.java:300)
at org.apache.flink.runtime.taskmanager.Task.run(Task.java:711)
at java.lang.Thread.run(Thread.java:748)
分享到
取消 提交回答
全部回答(1)
+ 订阅

大数据计算实践乐园,近距离学习前沿技术

推荐文章
相似问题
推荐课程