import org.apache.spark.SparkContext._
import org.apache.spark.SparkConf
import play.api.libs.json._
import java.util.Date
import javax.xml.bind.DatatypeConverter
object Test {
def main(args:Array[String]): Unit = {
val logFile="test.txt"
val conf=new SparkConf().setAppName("Json Test")
val sc = new SparkContext(conf)
try {
val out= "output/test"
val logData=sc.textFile(logFile,2).map(line => Json.parse(cleanTypo(line))).cache()
} finally {
sc.stop()
}
}
既然有人說,關於傑克遜的Spark衝突的問題,我一直在使用 MVN版本重建星火:用最新版本 - Dincludes = org.codehaus.jackson:傑克遜核心 - 翔升 MVN版本:用最新版本-Dincludes = org.codehaus.jackson:傑克遜映射器 - 翔升星火運行錯誤java.lang.NoClassDefFoundError:組織/ Codehaus的/傑克遜/註釋/ JsonClass
所以罐子已更新的1.9.x 但我仍然有錯誤
15/03/02 03:12:19 ERROR Executor: Exception in task 0.0 in stage 0.0 (TID 0)
java.lang.NoClassDefFoundError: org/codehaus/jackson/annotate/JsonClass
at org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector.findDeserializationType(JacksonAnnotationIntrospector.java:524)
at org.codehaus.jackson.map.deser.BasicDeserializerFactory.modifyTypeByAnnotation(BasicDeserializerFactory.java:732)
at org.codehaus.jackson.map.deser.BeanDeserializerFactory.createBeanDeserializer(BeanDeserializerFactory.java:427)
at org.codehaus.jackson.map.deser.StdDeserializerProvider._createDeserializer(StdDeserializerProvider.java:398)
at org.codehaus.jackson.map.deser.StdDeserializerProvider._createAndCache2(StdDeserializerProvider.java:307)
at org.codehaus.jackson.map.deser.StdDeserializerProvider._createAndCacheValueDeserializer(StdDeserializerProvider.java:287)
at org.codehaus.jackson.map.deser.StdDeserializerProvider.findValueDeserializer(StdDeserializerProvider.java:136)
at org.codehaus.jackson.map.deser.StdDeserializerProvider.findTypedValueDeserializer(StdDeserializerProvider.java:157)
at org.codehaus.jackson.map.ObjectMapper._findRootDeserializer(ObjectMapper.java:2468)
at org.codehaus.jackson.map.ObjectMapper._readValue(ObjectMapper.java:2383)
at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1094)
at play.api.libs.json.JacksonJson$.parseJsValue(JsValue.scala:477)
at play.api.libs.json.Json$.parse(Json.scala:16)
如果您使用spark-submit腳本,您是否使用'--jars'選項提供了jar的路徑? – BenFradet 2015-03-03 18:09:43
謝謝你的回覆。我試過了。我也試過spark.files.userClassPathFirst選項。沒有運氣。 – Wendy 2015-03-04 20:07:29