gpt4 book ai didi

java - 加载 Hive 内置函数失败

转载 作者:可可西里 更新时间:2023-11-01 15:39:20 27 4
gpt4 key购买 nike

我正在尝试创建一个测试,将 hive 作为本地计算机上的独立服务器启动。

这是我的设置代码:

@Before
public void setupHive() throws MetaException, IOException, TException {
//Create and configure location for hive to dump junk in target folder
FileUtils.forceMkdir(HIVE_BASE_DIR);
FileUtils.forceMkdir(HIVE_SCRATCH_DIR);
FileUtils.forceMkdir(HIVE_LOCAL_SCRATCH_DIR);
FileUtils.forceMkdir(HIVE_LOGS_DIR);
FileUtils.forceMkdir(HIVE_TMP_DIR);
FileUtils.forceMkdir(HIVE_WAREHOUSE_DIR);
FileUtils.forceMkdir(HIVE_HADOOP_TMP_DIR);
FileUtils.forceMkdir(HIVE_TESTDATA_DIR);

System.setProperty("javax.jdo.option.ConnectionURL", "jdbc:derby:;databaseName=" + HIVE_METADB_DIR.getAbsolutePath() + ";create=true");
System.setProperty("hive.metastore.warehouse.dir", HIVE_WAREHOUSE_DIR.getAbsolutePath());
System.setProperty("hive.exec.scratchdir", HIVE_SCRATCH_DIR.getAbsolutePath());
System.setProperty("hive.exec.local.scratchdir", HIVE_LOCAL_SCRATCH_DIR.getAbsolutePath());
System.setProperty("hive.metastore.metadb.dir", HIVE_METADB_DIR.getAbsolutePath());
System.setProperty("test.log.dir", HIVE_LOGS_DIR.getAbsolutePath());
System.setProperty("hive.querylog.location", HIVE_TMP_DIR.getAbsolutePath());
System.setProperty("hadoop.tmp.dir", HIVE_HADOOP_TMP_DIR.getAbsolutePath());
System.setProperty("derby.stream.error.file", HIVE_BASE_DIR.getAbsolutePath() + "/derby.log");

client = new HiveServer.HiveServerHandler();

}

但是我遇到了这个异常:

java.lang.RuntimeException: Failed to load Hive builtin functions
at org.apache.hadoop.hive.ql.session.SessionState.<init>(SessionState.java:190)
at org.apache.hadoop.hive.service.HiveServer$HiveServerHandler.<init>(HiveServer.java:135)
at org.apache.hadoop.hive.service.HiveServer$HiveServerHandler.<init>(HiveServer.java:121)
at com.outbrain.bizguard.guard.publisherInstallationHealth.subTests.HiveTests.setupHive(HiveTests.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
Caused by: java.lang.ClassNotFoundException: org.apache.hive.builtins.BuiltinUtils
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at org.apache.hadoop.hive.ql.exec.Utilities.getBuiltinUtilsClass(Utilities.java:2280)
at org.apache.hadoop.hive.ql.session.SessionState.<init>(SessionState.java:182)
... 24 more

我使用 Intellij

最佳答案

原来问题只是缺少一个 jar 。我将此依赖项添加到我的 pom.xml 中,现在它可以工作了:

 <dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-builtins</artifactId>
<version>0.8.1</version>
</dependency>

关于java - 加载 Hive 内置函数失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19368641/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com