我试图从java程序中使用Spark SQL,其中pom.xml中的依赖关系指向Spark版本1.6.0。下面是程序
package spark_test;
import java.util.List;
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.sql.DataFrame;
import org.apache.spark.sql.SQLContext;
import org.apache.spark.sql.hive.HiveContext;
public class MyTest {
private static SparkConf sparkConf;
public static void main(String[] args) {
String warehouseLocation = args[0];
sparkConf = new SparkConf().setAppName("Hive Test").setMaster("local[*]")
.set("spark.sql.warehouse.dir", warehouseLocation);
JavaSparkContext ctx = new JavaSparkContext(sparkConf);
SQLContext sc = new HiveContext(ctx.sc());
System.out.println(" Current Tables: ");
DataFrame results = sc.sql("show tables");
results.show();
}
}
但是,我在线程“main”java.lang.nosuchmethoderror:org.apache.spark.sql.sqlcontext.sql(ljava/lang/string;)lorg/apache/spark/sql/dataframe中出现异常;我正在创建一个平面jar并从命令行运行该jar
Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/cloudera/workspace/slf4j-log4j12-1.7.16.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/cloudera/workspace/PortalHandlerTest.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/cloudera/workspace/SparkTest.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/home/cloudera/workspace/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/cloudera/workspace/JARs/slf4j-log4j12-1.7.22.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/lib/zookeeper/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
17/04/25 08:44:07 INFO SparkContext: Running Spark version 2.1.0
17/04/25 08:44:07 WARN SparkContext: Support for Java 7 is deprecated as of Spark 2.0.0
17/04/25 08:44:07 WARN SparkContext: Support for Scala 2.10 is deprecated as of Spark 2.1.0
17/04/25 08:44:08 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
17/04/25 08:44:08 INFO SecurityManager: Changing view acls to: cloudera
17/04/25 08:44:08 INFO SecurityManager: Changing modify acls to: cloudera
17/04/25 08:44:08 INFO SecurityManager: Changing view acls groups to:
17/04/25 08:44:08 INFO SecurityManager: Changing modify acls groups to:
17/04/25 08:44:08 INFO SecurityManager: SecurityManager: authentication disabled; ui acls disabled; users with view permissions: Set(cloudera); groups with view permissions: Set(); users with modify permissions: Set(cloudera); groups with modify permissions: Set()
17/04/25 08:44:09 INFO Utils: Successfully started service 'sparkDriver' on port 43850.
17/04/25 08:44:09 INFO SparkEnv: Registering MapOutputTracker
17/04/25 08:44:09 INFO SparkEnv: Registering BlockManagerMaster
17/04/25 08:44:09 INFO BlockManagerMasterEndpoint: Using org.apache.spark.storage.DefaultTopologyMapper for getting topology information
17/04/25 08:44:09 INFO BlockManagerMasterEndpoint: BlockManagerMasterEndpoint up
17/04/25 08:44:09 INFO DiskBlockManager: Created local directory at /tmp/blockmgr-4199c353-4e21-4863-8b78-cfa280ce2de3
17/04/25 08:44:09 INFO MemoryStore: MemoryStore started with capacity 375.7 MB
17/04/25 08:44:09 INFO SparkEnv: Registering OutputCommitCoordinator
17/04/25 08:44:09 WARN Utils: Service 'SparkUI' could not bind on port 4040. Attempting port 4041.
17/04/25 08:44:09 INFO Utils: Successfully started service 'SparkUI' on port 4041.
17/04/25 08:44:09 INFO SparkUI: Bound SparkUI to 0.0.0.0, and started at http://10.0.2.15:4041
17/04/25 08:44:10 INFO Executor: Starting executor ID driver on host localhost
17/04/25 08:44:10 INFO Utils: Successfully started service 'org.apache.spark.network.netty.NettyBlockTransferService' on port 41716.
17/04/25 08:44:10 INFO NettyBlockTransferService: Server created on 10.0.2.15:41716
17/04/25 08:44:10 INFO BlockManager: Using org.apache.spark.storage.RandomBlockReplicationPolicy for block replication policy
17/04/25 08:44:10 INFO BlockManagerMaster: Registering BlockManager BlockManagerId(driver, 10.0.2.15, 41716, None)
17/04/25 08:44:10 INFO BlockManagerMasterEndpoint: Registering block manager 10.0.2.15:41716 with 375.7 MB RAM, BlockManagerId(driver, 10.0.2.15, 41716, None)
17/04/25 08:44:10 INFO BlockManagerMaster: Registered BlockManager BlockManagerId(driver, 10.0.2.15, 41716, None)
17/04/25 08:44:10 INFO BlockManager: Initialized BlockManager: BlockManagerId(driver, 10.0.2.15, 41716, None)
Current Tables:
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.spark.sql.SQLContext.sql(Ljava/lang/String;)Lorg/apache/spark/sql/DataFrame;
at spark_test.MyTest.main(MyTest.java:31)
17/04/25 08:44:10 INFO SparkContext: Invoking stop() from shutdown hook
17/04/25 08:44:10 INFO SparkUI: Stopped Spark web UI at http://10.0.2.15:4041
17/04/25 08:44:10 INFO MapOutputTrackerMasterEndpoint: MapOutputTrackerMasterEndpoint stopped!
17/04/25 08:44:10 INFO MemoryStore: MemoryStore cleared
17/04/25 08:44:10 INFO BlockManager: BlockManager stopped
17/04/25 08:44:10 INFO BlockManagerMaster: BlockManagerMaster stopped
17/04/25 08:44:10 INFO OutputCommitCoordinator$OutputCommitCoordinatorEndpoint: OutputCommitCoordinator stopped!
17/04/25 08:44:10 INFO SparkContext: Successfully stopped SparkContext
17/04/25 08:44:10 INFO ShutdownHookManager: Shutdown hook called
17/04/25 08:44:10 INFO ShutdownHookManager: Deleting directory /tmp/spark-93fca3d1-ff79-4d2b-b07f-a340c1a60416
如有任何帮助,不胜感激。
在Spark2中,DataFrame()被Dataset()取代。如果运行带有Spark2.1服务器端的Spark1.6客户机,则需要导入org.apache.Spark.sql.DataSet并使用它。这里有更多信息。从开发人员体验的角度来看,大多数API是相似的。不过,老实说,如果不是服务器版本,至少在客户机中使用Spark2.0依赖项会更好。
Animal.java 我为它创建了以下自定义断言: AnimalAssert.java 编辑:基于第一个答案(cglib需要一个),我用一个no arg构造函数更新了动物类,但是抛出了相同的异常
我的应用程序一直在许多Android平台上报告这个问题(4.1、4.0.4、2.3.6.…)。但我无法在我的手机上复制这个问题。我已经在Google上搜索了这个问题,但堆栈跟踪似乎与我的不一样。
我有一台带有Intel CPU的Windows机器(在引导菜单上启用VMX)。我使用VirtualBox在上面运行Ubuntu Guest。我在上面运行qemu,以运行另一个Guest OS,使用kvm(选项)。 我在尝试插入kvm-intel模块时收到以下错误: 我已经检查了来宾操作系统中的vpx标志,但我也没有看到 有没有办法在来宾Ubuntu操作系统中启用kvm支持,以便我可以在Ubuntu
主机系统为ARCHLinux。我想开发需要运行Windows docker容器的.NET4.6.1应用程序。所以我在VirtualBox下运行Win10。然后我在Win10中安装Docker,以运行Windows Docker容器。Linux->VirtualBox->Win10->Docker->Windows Docker容器->要运行的应用程序。 或者更具体地说,VirtualBox是否支持
问题内容: 我正在尝试根据此教程在我的应用程序中实现NotificationListenerService:http : //www.kpbird.com/2013/07/android- notificationlistenerservice.html ,但是调用getActiveNotifications时出现NullPointerException。 我正在向该服务发送广播,该广播应生成所有
问题内容: 因此,我正在构建一个minecraft插件,该插件的一部分从mysql抓取一堆数据块,并在服务器启动时将其加载到缓存中。我有一些代码可以在Eclipse测试用例中正常运行。但是,当我在本地Minecraft服务器中加载插件时,出现了异常。 抛出异常的代码。 是从执行查询返回的实例。 只是返回一个 片段稍大…并不是真的可以显示其他内容。 我看过网上有人说要修复,我需要包括ojdbc6.j