Spark with json4s, parse function raise java.lang.NoSuchMethodError: org.json4s.jackson.JsonMethods$.parse$default$3()Z

一个人想着一个人 提交于 2021-01-27 23:07:54

问题


I wrote a function to process stream by spark streaming. And I encountered java.lang.NoSuchMethodError: org.json4s.jackson.JsonMethods$.parse$default$3()Z

I have checked about the spark version(1.6.0) and scala version(2.10.5). It is consistent with json4s jar version(json4s-jackson_2.10-3.3.0.jar). I can not figure out what happened. And the following is the function code:

    import org.json4s._
    import org.json4s.jackson.Serialization.{read => JsonRead}
    import org.json4s.jackson.JsonMethods._

    def processStream(ssc: StreamingContext, windowStream: DStream[Array[Byte]], eventhubsId: Int): Unit = {
        /*
         ...
        */
        val successStream = eventsStream.filter(_.isSuccess).map(_.get)
        val successEventDataWindowStream = successStream.map(x => {
            val eventDataStr = x._2.getOrElse("")
            implicit val formats = jackson.Serialization.formats(NoTypeHints)
            Try(parse(eventDataStr).camelizeKeys.extract[EventData]) match {
                case Success(eventData) => Success(eventData)
                case Failure(ex) => Failure(ex)
            }
        })
    }

来源:https://stackoverflow.com/questions/38650862/spark-with-json4s-parse-function-raise-java-lang-nosuchmethoderror-org-json4s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!