c# - JVM方法执行失败: Nonstatic method load failed for class 14 when called with no parameters

标签 c# hive mobius

我正在尝试运行 Mobius HiveDataFrame 示例,但无法运行。

        var jsonFilePath = "file:///C:/Mobius/build/runtime/data/people.json";
        const string dbName = "SampleHiveDataBaseForMobius";
        const string tableName = "people";

        var builder = SparkSession.Builder().EnableHiveSupport();
        // The following setting is required to use Spark 2.0 in Windows
        // It may be provided in command line when running Mobius app
        //builder = builder.Config("spark.sql.warehouse.dir", "<hdfs or local path>");
        var session = builder.GetOrCreate();
        var peopleDataFrame = session.Read().Json(jsonFilePath);
        session.Sql(string.Format("CREATE DATABASE IF NOT EXISTS {0}", dbName)); // create database if not exists
        session.Sql(string.Format("USE {0}", dbName));
        //hiveContext.Sql(string.Format("DROP TABLE {0}", tableName)); // drop table if exists

        peopleDataFrame.Write().Mode(SaveMode.Overwrite).SaveAsTable(tableName); // create table
        var tablesDataFrame = session.Table(tableName); // get all tables in database
        logger.LogInfo(string.Format("table count in database {0}: {1}", dbName, tablesDataFrame.Count()));
        tablesDataFrame.Show();

        session.Sql(string.Format("SELECT * FROM {0}", tableName)).Show(); // select from table

我收到错误@

var peopleDataFrame = session.Read().Json(jsonFilePath);

来源:Microsoft.Spark.CSharp.Adapter

消息:JVM 方法执行失败:在不带参数调用时,类 14 的非静态方法加载失败

这是堆栈跟踪

Microsoft.Spark.CSharp.Interop.Ipc.JvmBridge.CallJavaMethod(Boolean isStatic, Object classNameOrJvmObjectReference, String methodName, Object[] parameters)
Microsoft.Spark.CSharp.Interop.Ipc.JvmBridge.CallNonStaticJavaMethod(JvmObjectReference objectId, String methodName)
Microsoft.Spark.CSharp.Proxy.Ipc.DataFrameReaderIpcProxy.Load()
Microsoft.Spark.CSharp.Sql.DataFrameReader.Load()
Microsoft.Spark.CSharp.Sql.DataFrameReader.Load(String path)
Microsoft.Spark.CSharp.Sql.DataFrameReader.Json(String path)
DemoSparkHiveDataFrame.Program.Main(String[] args) in e:\Work\Feb\VS 2012\DemoSparkHiveDataFrame\DemoSparkHiveDataFrame\Program.cs:line 26
System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
System.Threading.ThreadHelper.ThreadStart_Context(Object state)
System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
System.Threading.ThreadHelper.ThreadStart()

最佳答案

我有一个只需设置的解决方案

builder.config("spark.sql.warehouse.dir","file:///C:/spark-warehouse") 

对于设置spark.sql.warehouse.dir路径,它对我来说效果很好。

关于c# - JVM方法执行失败: Nonstatic method load failed for class 14 when called with no parameters,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42902318/

相关文章:

c# - SparkClr : Sparkcontext gives an Error

c# - Java MongoDB Hadoop 连接器是否有 C# 等效项?

c# - 如何在 Linq To Entities 中维护事务

c# - 为什么不能将 Action<Object> 委托(delegate)用作线程池的 WaitCallback?

hadoop - 将 CSV 数据加载到 Hive ORC 表中

hadoop - 如何从 “SQL View”导入到Sqoop Hive

c# - 有没有办法从 Mobius 从 hdfs 中的 Parquet 文件读取到 SqlContext?

c# - 检查 TreeView 是否有变化?

c# - 为什么我在调用 Func<int> 时会得到错误的结果?

amazon-web-services - 在 emr 上重启 hiveserver2