无法加载Hive内置函数

时间:2013-10-14 20:22:29

标签: java hadoop intellij-idea hive

我正在尝试创建一个将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

1 个答案:

答案 0 :(得分:1)

原来问题只是一个丢失的罐子。我将此依赖项添加到我的pom.xml,现在它可以正常工作:

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