当前位置: 首页 > 面试题库 >

Windows中出现火花失败: :16:错误:未找到:值sqlContext

鲁涵意
2023-03-14
问题内容

我在Windows上安装了spark,但无法运行,并显示以下错误:

<console>:16: error: not found: value sqlContext
         import sqlContext.implicits._
                ^
<console>:16: error: not found: value sqlContext
         import sqlContext.sql
                ^

火花执行的完整日志如下:

   D:\Spark\spark-1.6.1-bin-hadoop2.6\bin>spark-shell
    log4j:WARN No appenders could be found for logger (org.apache.hadoop.metrics2.lib.MutableMetricsFactory).
    log4j:WARN Please initialize the log4j system properly.
    log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
    Using Spark's repl log4j profile: org/apache/spark/log4j-defaults-repl.properties
    To adjust logging level use sc.setLogLevel("INFO")
    Welcome to
          ____              __
         / __/__  ___ _____/ /__
        _\ \/ _ \/ _ `/ __/  '_/
       /___/ .__/\_,_/_/ /_/\_\   version 1.6.1
          /_/

    Using Scala version 2.10.5 (Java HotSpot(TM) Client VM, Java 1.8.0_77)
    Type in expressions to have them evaluated.
    Type :help for more information.
    Spark context available as sc.
    16/04/19 16:28:10 WARN General: Plugin (Bundle) "org.datanucleus.api.jdo" is already registered. Ensure you dont have mul
    tiple JAR versions of the same plugin in the classpath. The URL "file:/D:/Spark/spark-1.6.1-bin-hadoop2.6/lib/datanucleus
    -api-jdo-3.2.6.jar" is already registered, and you are trying to register an identical plugin located at URL "file:/D:/Sp
    ark/spark-1.6.1-bin-hadoop2.6/bin/../lib/datanucleus-api-jdo-3.2.6.jar."
    16/04/19 16:28:10 WARN General: Plugin (Bundle) "org.datanucleus" is already registered. Ensure you dont have multiple JA
    R versions of the same plugin in the classpath. The URL "file:/D:/Spark/spark-1.6.1-bin-hadoop2.6/lib/datanucleus-core-3.
    2.10.jar" is already registered, and you are trying to register an identical plugin located at URL "file:/D:/Spark/spark-
    1.6.1-bin-hadoop2.6/bin/../lib/datanucleus-core-3.2.10.jar."
    16/04/19 16:28:10 WARN General: Plugin (Bundle) "org.datanucleus.store.rdbms" is already registered. Ensure you dont have
     multiple JAR versions of the same plugin in the classpath. The URL "file:/D:/Spark/spark-1.6.1-bin-hadoop2.6/bin/../lib/
    datanucleus-rdbms-3.2.9.jar" is already registered, and you are trying to register an identical plugin located at URL "fi
    le:/D:/Spark/spark-1.6.1-bin-hadoop2.6/lib/datanucleus-rdbms-3.2.9.jar."
    16/04/19 16:28:11 WARN Connection: BoneCP specified but not present in CLASSPATH (or one of dependencies)
    16/04/19 16:28:11 WARN Connection: BoneCP specified but not present in CLASSPATH (or one of dependencies)
    16/04/19 16:28:24 WARN ObjectStore: Version information not found in metastore. hive.metastore.schema.verification is not
     enabled so recording the schema version 1.2.0
    16/04/19 16:28:24 WARN ObjectStore: Failed to get database default, returning NoSuchObjectException
    java.lang.RuntimeException: java.lang.NullPointerException
            at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:522)
            at org.apache.spark.sql.hive.client.ClientWrapper.<init>(ClientWrapper.scala:204)
            at org.apache.spark.sql.hive.client.IsolatedClientLoader.createClient(IsolatedClientLoader.scala:238)
            at org.apache.spark.sql.hive.HiveContext.executionHive$lzycompute(HiveContext.scala:218)
            at org.apache.spark.sql.hive.HiveContext.executionHive(HiveContext.scala:208)
            at org.apache.spark.sql.hive.HiveContext.functionRegistry$lzycompute(HiveContext.scala:462)
            at org.apache.spark.sql.hive.HiveContext.functionRegistry(HiveContext.scala:461)
            at org.apache.spark.sql.UDFRegistration.<init>(UDFRegistration.scala:40)
            at org.apache.spark.sql.SQLContext.<init>(SQLContext.scala:330)
            at org.apache.spark.sql.hive.HiveContext.<init>(HiveContext.scala:90)
            at org.apache.spark.sql.hive.HiveContext.<init>(HiveContext.scala:101)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
            at java.lang.reflect.Constructor.newInstance(Unknown Source)
            at org.apache.spark.repl.SparkILoop.createSQLContext(SparkILoop.scala:1028)
            at $iwC$$iwC.<init>(<console>:15)
            at $iwC.<init>(<console>:24)
            at <init>(<console>:26)
            at .<init>(<console>:30)
            at .<clinit>(<console>)
            at .<init>(<console>:7)
            at .<clinit>(<console>)
            at $print(<console>)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at org.apache.spark.repl.SparkIMain$ReadEvalPrint.call(SparkIMain.scala:1065)
            at org.apache.spark.repl.SparkIMain$Request.loadAndRun(SparkIMain.scala:1346)
            at org.apache.spark.repl.SparkIMain.loadAndRunReq$1(SparkIMain.scala:840)
            at org.apache.spark.repl.SparkIMain.interpret(SparkIMain.scala:871)
            at org.apache.spark.repl.SparkIMain.interpret(SparkIMain.scala:819)
            at org.apache.spark.repl.SparkILoop.reallyInterpret$1(SparkILoop.scala:857)
            at org.apache.spark.repl.SparkILoop.interpretStartingWith(SparkILoop.scala:902)
            at org.apache.spark.repl.SparkILoop.command(SparkILoop.scala:814)
            at org.apache.spark.repl.SparkILoopInit$$anonfun$initializeSpark$1.apply(SparkILoopInit.scala:132)
            at org.apache.spark.repl.SparkILoopInit$$anonfun$initializeSpark$1.apply(SparkILoopInit.scala:124)
            at org.apache.spark.repl.SparkIMain.beQuietDuring(SparkIMain.scala:324)
            at org.apache.spark.repl.SparkILoopInit$class.initializeSpark(SparkILoopInit.scala:124)
            at org.apache.spark.repl.SparkILoop.initializeSpark(SparkILoop.scala:64)
            at org.apache.spark.repl.SparkILoop$$anonfun$org$apache$spark$repl$SparkILoop$$process$1$$anonfun$apply$mcZ$sp$5.
    apply$mcV$sp(SparkILoop.scala:974)
            at org.apache.spark.repl.SparkILoopInit$class.runThunks(SparkILoopInit.scala:159)
            at org.apache.spark.repl.SparkILoop.runThunks(SparkILoop.scala:64)
            at org.apache.spark.repl.SparkILoopInit$class.postInitialization(SparkILoopInit.scala:108)
            at org.apache.spark.repl.SparkILoop.postInitialization(SparkILoop.scala:64)
            at org.apache.spark.repl.SparkILoop$$anonfun$org$apache$spark$repl$SparkILoop$$process$1.apply$mcZ$sp(SparkILoop.
    scala:991)
            at org.apache.spark.repl.SparkILoop$$anonfun$org$apache$spark$repl$SparkILoop$$process$1.apply(SparkILoop.scala:9
    45)
            at org.apache.spark.repl.SparkILoop$$anonfun$org$apache$spark$repl$SparkILoop$$process$1.apply(SparkILoop.scala:9
    45)
            at scala.tools.nsc.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:135)
            at org.apache.spark.repl.SparkILoop.org$apache$spark$repl$SparkILoop$$process(SparkILoop.scala:945)
            at org.apache.spark.repl.SparkILoop.process(SparkILoop.scala:1059)
            at org.apache.spark.repl.Main$.main(Main.scala:31)
            at org.apache.spark.repl.Main.main(Main.scala)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:731)
            at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:181)
            at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:206)
            at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:121)
            at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
    Caused by: java.lang.NullPointerException
            at java.lang.ProcessBuilder.start(Unknown Source)
            at org.apache.hadoop.util.Shell.runCommand(Shell.java:482)
            at org.apache.hadoop.util.Shell.run(Shell.java:455)
            at org.apache.hadoop.util.Shell$ShellCommandExecutor.execute(Shell.java:715)
            at org.apache.hadoop.util.Shell.execCommand(Shell.java:808)
            at org.apache.hadoop.util.Shell.execCommand(Shell.java:791)
            at org.apache.hadoop.fs.FileUtil.execCommand(FileUtil.java:1097)
            at org.apache.hadoop.fs.RawLocalFileSystem$DeprecatedRawLocalFileStatus.loadPermissionInfo(RawLocalFileSystem.jav
    a:582)
            at org.apache.hadoop.fs.RawLocalFileSystem$DeprecatedRawLocalFileStatus.getPermission(RawLocalFileSystem.java:557
    )
            at org.apache.hadoop.hive.ql.session.SessionState.createRootHDFSDir(SessionState.java:599)
            at org.apache.hadoop.hive.ql.session.SessionState.createSessionDirs(SessionState.java:554)
            at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:508)
            ... 62 more

    <console>:16: error: not found: value sqlContext
             import sqlContext.implicits._
                    ^
    <console>:16: error: not found: value sqlContext
             import sqlContext.sql
                    ^

    scala>

问题答案:

正如您发布的链接中所述,我遇到了完全相同的问题,并经历了许多可能的解决方案,但当时没有任何效果。通过运行spark-shell命令,它将在C:中创建tmp
\ hive目录,并最终发现权限存在问题。我确保我的HADOOP_HOME设置正确并且包含\ bin \ winutils.exe,然后将tmp \
hive移至%HADOOP_HOME%\ bin下并重新启动命令提示符。这终于解决了问题,但请记住要以管理员身份运行cmd。希望这会有所帮助,我。



 类似资料:
  • 我刚从Spark开始。我已经用Spark安装了CDH5。然而,当我尝试使用sparkcontext时,它给出了如下错误 我对此进行了研究,发现了错误:未找到:值sc 并试图启动火花上下文。/Spark-shell。它给错误

  • 我在运行下面我写的SPARK代码时出错了。我试图根据键找到所有向量的总和。每个输入行以键(整数)开始,然后是127个浮点数,这是一个具有127个维度的单个向量,即每一行以键和向量开始。

  • 运行命令vc时。sql(testsql),出现以下错误 通用域名格式。液火花沃拉。VoraConfigurationException:未找到ZooKeeper主机 动物园管理员在所有三个节点上启动并运行服务。 错误日志显示以下内容: 2016-09-14 15:14:32418-信息[NIOServerCxn.工厂:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactor

  • 我使用hadoop 2.7.2,hbase 1.4.9,火花2.2.0,scala 2.11.8和java 1.8的hadoop集群是由一个主和两个从。 当我在启动集群后运行spark shell时,它工作正常。我正试图通过以下教程使用scala连接到hbase:[https://www.youtube.com/watch?v=gGwB0kCcdu0][1] . 但当我试图像他那样通过添加那些类似

  • 几周前,我正在编写一个应用程序。当时它正在工作并成功运行。今天,我尝试打开Android Studio,但在gradle构建中不断出现以下错误: 我不知道该怎么办。我谷歌了一下,并尝试了一些答案,比如删除. gradle文件夹中的脚本文件夹,然后重新启动Android Studio,但这没有帮助。 编辑=我尝试复制“缓存”。属性的文件。。。2.8/cache文件夹到我的项目中。它确实深入到了gra

  • 我正在尝试使用Spring Boot 1.5.9在Spring数据存储库中实现自定义方法。释放我创建了存储库: 提供了自定义存储库: 以及实施: 此外,我还提供了一个调用: 只是由spring初始值设定项生成的普通xml: 在Spring Boot 1.5.9上运行项目时。RELEASE我在容器创建时遇到了一个问题: 将Spring Boot版本更改为2.1.9。发布效果很好,给了我预期的结果。