英文:
Writesteams failing with java.lang.NoClassDefFoundError
问题
query.writeStream.outputMode("append").format("console").trigger(continuous="1 second").start()
我正在尝试在databricks中将writeStreams用于我的代码,我的代码语句是:
我正在从Cosmos读取MongoDB。
我得到的错误是:
java.lang.NoClassDefFoundError: Could not initialize class com.mongodb.spark.sql.connector.read.MongoScanBuilder
集群详情:12.2 LTS(包括Apache Spark 3.3.2,Scala 2.12)
在集群中安装的库:
org.mongodb.spark:mongo-spark-connector_2.13:10.2.0
英文:
I am trying to use writeStreams in databricks into my code, My code statement is:
query.writeStream.outputMode("append").format("console").trigger(continuous="1 second").start()
I am reading from Cosmos for Mongo DB.
The error i am getting is:
java.lang.NoClassDefFoundError: Could not initialize class com.mongodb.spark.sql.connector.read.MongoScanBuilder
Custer Details : 12.2 LTS (includes Apache Spark 3.3.2, Scala 2.12)
Libraries installed in the cluster:
org.mongodb.spark:mongo-spark-connector_2.13:10.2.0
答案1
得分: 1
你正在使用为Scala 2.13编译的库,而Databricks使用了与Scala 2.12编译的Spark,因此这些库不兼容。您需要使用org.mongodb.spark:mongo-spark-connector_2.12:10.2.0
版本代替(链接)。
英文:
You are using a library compiled for Scala 2.13, while Databricks uses Spark compiled with Scala 2.12, so libraries are incompatible. You need to use org.mongodb.spark:mongo-spark-connector_2.12:10.2.0
version instead (link).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论