问题
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