Writesteams 失败,出现 java.lang.NoClassDefFoundError 错误。

huangapple go评论115阅读模式
英文:

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).

huangapple
  • 本文由 发表于 2023年7月20日 19:38:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/76729454.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定