我正在使用spark 1.3.0和spark-avro 1.0.0。我的build.sbt文件看起来像
libraryDependencies ++=Seq(
"org.apache.spark" % "spark-core_2.10" % "1.3.0" % "provided",
"org.apache.spark" % "spark-sql_2.10" % "1.5.2" % "provided",
"com.databricks" % "spark-avro_2.10" % "1.0.0",
"org.apache.avro" % "avro" % "1.7.7",
"org.apache.avro" % "avro-mapred" % "1.7.7",
"org.apache.spark" % "spark-hive_2.10" % "1.0.0" % "provided",
"joda-time" % "joda-time" % "2.9.2",
"org.joda" % "joda-convert" % "1.8.1",
"commons-codec" % "commons-codec" % "1.9"
)
我正在使用程序集插件构建一个胖jar。
但有时我的代码会因以下错误而失败。如果我做了jar -tf Fooassembly.jar
我可以在' com / databricks / spark / avro'中看到很多.class文件。夹。所以我不确定为什么抱怨这个特殊的课程。
Exception in thread "main" java.lang.NoClassDefFoundError: com/databricks/spark/avro/package$
at com.databricks.spark.avro.DefaultSource.createRelation(DefaultSource.scala:78)
at org.apache.spark.sql.sources.ResolvedDataSource$.apply(ddl.scala:308)
at org.apache.spark.sql.DataFrame.save(DataFrame.scala:1123)
at org.apache.spark.sql.DataFrame.save(DataFrame.scala:1083)
at com.abhi.FormNameMatcher$$anonfun$main$1.apply(FormNameMatcher.scala:89)
at com.abhi.FormNameMatcher$$anonfun$main$1.apply(FormNameMatcher.scala:83)
at scala.collection.Iterator$class.foreach(Iterator.scala:727)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1157)
at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
at com.abhi.FormNameMatcher$.main(FormNameMatcher.scala:83)
at com.abhi.FormNameMatcher.main(FormNameMatcher.scala)
答案 0 :(得分:1)
spark avro应与spark本身兼容。尝试修复spark core和spark sql之间的兼容性(应该是相同的版本),然后选择兼容版本的spark-avro(https://github.com/databricks/spark-avro请参阅要求部分)