如何解决“java.lang.ClassNotFoundException”使用 databricks-connect 运行 Scala Spark 项目时?

发布于 2025-01-16 12:37:10 字数 1721 浏览 4 评论 0原文

目前我正在学习如何使用databricks-connect在本地使用IDE开发Scala代码。 databricks-connect 的设置如 此处所述 是成功的。这是一个假设,因为我可以毫无问题地对集群运行 PySpark 代码。

但是,我很难运行 Scala 中提供的 scala 示例演示对象。我收到 java.lang.ClassNotFoundException:这里是异常的完整跟踪:

StackTrace

我的 build.sbt 严格遵循 Databricks-connect 演示提供的内容:

scalaVersion := "2.12.15"
name := "hello-world"
organization := "ch.epfl.scala"
version := "1.0"
//autoScalaLibrary := true
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "2.1.1"
unmanagedBase := new java.io.File("/home/clh78p/.local/lib/python3.8/site-packages/pyspark/jars")
mainClass := Some("Main")

我的集群配置是更新,我密切关注以下 databricks-连接客户端安装手册准确。

SparkConfig

我读过这里的帖子和这个帖子。它们让我觉得我缺少一些 jar 或库依赖项,而演示中可能未涵盖这些依赖项?我确保 scala 版本匹配,所以这应该不是问题。欢迎任何建议。

请注意,我将 VS Code 与 WSL2 和 Databricks Azure 选项结合使用。我目前正在学习 Scala 以取代 PySpark Notebooks。

Currently I am learning how to use databricks-connect to develop Scala code using IDE locally. The set-up of the databricks-connect as described here was succuesful. This is an assumption as I can run PySpark Code against the cluster with no issues.

However, I struggle to run the scala example as provided in the Scala demo object. I receive the java.lang.ClassNotFoundException: Here the full trace of the Exception:

StackTrace

My build.sbt follows closely what was provided with the Databricks-connect demo:

scalaVersion := "2.12.15"
name := "hello-world"
organization := "ch.epfl.scala"
version := "1.0"
//autoScalaLibrary := true
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "2.1.1"
unmanagedBase := new java.io.File("/home/clh78p/.local/lib/python3.8/site-packages/pyspark/jars")
mainClass := Some("Main")

My clusters configuration is up-date and I payed close attention to following the databricks-connect client installation manual precisely.

SparkConfig

I read amongst others the post here and this post. They make me think I am missing some jar or a library dependency which may not be covered in the demo? I made sure the scala versions match, so this should hopefully not be the problem. Any advice is welcome.

Note that I use VS Code with WSL2 and the Databricks Azure option. I am learning Scala at the moment to replace PySpark Notebooks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文