hive-builtins文件找不到

java.io.FileNotFoundException: File does not exist: hdfs://localhost:8020/home/fatkun/hive-0.10.0-cdh4.3.0/lib/hive-builtins-0.10.0-cdh4.3.0.jar
	at org.apache.hadoop.hdfs.DistributedFileSystem.getFileStatus(DistributedFileSystem.java:824)
	at org.apache.hadoop.mapreduce.filecache.ClientDistributedCacheManager.getFileStatus(ClientDistributedCacheManager.java:288)
	at org.apache.hadoop.mapreduce.filecache.ClientDistributedCacheManager.getFileStatus(ClientDistributedCacheManager.java:224)
	at org.apache.hadoop.mapreduce.filecache.ClientDistributedCacheManager.determineTimestamps(ClientDistributedCacheManager.java:93)
	at org.apache.hadoop.mapreduce.filecache.ClientDistributedCacheManager.determineTimestampsAndCacheVisibilities(ClientDistributedCacheManager.java:57)
	at org.apache.hadoop.mapreduce.JobSubmitter.copyAndConfigureFiles(JobSubmitter.java:254)
	at org.apache.hadoop.mapreduce.JobSubmitter.copyAndConfigureFiles(JobSubmitter.java:290)
	at org.apache.hadoop.mapreduce.JobSubmitter.submitJobInternal(JobSubmitter.java:361)
	at org.apache.hadoop.mapreduce.Job$11.run(Job.java:1269)
	at org.apache.hadoop.mapreduce.Job$11.run(Job.java:1266)
	at java.security.AccessController.doPrivileged(Native Method)
	at javax.security.auth.Subject.doAs(Subject.java:396)
	at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1408)
	at org.apache.hadoop.mapreduce.Job.submit(Job.java:1266)
	at org.apache.hadoop.mapred.JobClient$1.run(JobClient.java:606)
	at org.apache.hadoop.mapred.JobClient$1.run(JobClient.java:601)
	at java.security.AccessController.doPrivileged(Native Method)
	at javax.security.auth.Subject.doAs(Subject.java:396)
	at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1408)
	at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:601)
	at org.apache.hadoop.mapred.JobClient.submitJob(JobClient.java:586)
	at org.apache.hadoop.hive.ql.exec.ExecDriver.execute(ExecDriver.java:448)
	at org.apache.hadoop.hive.ql.exec.ExecDriver.main(ExecDriver.java:690)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.hadoop.util.RunJar.main(RunJar.java:208)
Job Submission failed with exception 'java.io.FileNotFoundException(File does not exist: hdfs://localhost:8020/home/fatkun/hive-0.10.0-cdh4.3.0/lib/hive-builtins-0.10.0-cdh4.3.0.jar)'

可能的原因

刚开始我用伪分布模式没有提示这个错误,我配置了mapred-site.xml为local模式,但core-site.xml使用hdfs,从hdfs找不到这个文件。

可能的代码

//ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java

   // Register the Hive builtins jar and all of its functions
    try {
      Class<?> pluginClass = Utilities.getBuiltinUtilsClass();
      URL jarLocation = pluginClass.getProtectionDomain().getCodeSource()
        .getLocation();
      add_builtin_resource(
        ResourceType.JAR, jarLocation.toString());
      FunctionRegistry.registerFunctionsFromPluginJar(
        jarLocation, pluginClass.getClassLoader());
      sessionFunctionRegistry.putAll(FunctionRegistry.getStaticFunctionRegistry());
    } catch (Exception ex) {
      throw new RuntimeException("Failed to load Hive builtin functions", ex);
    }

解决方法

方法一:
更改core.site.xml,把fs.default.name改成local

<property>
    <name>fs.default.name</name>
    <value>file:///</value>
  </property>

方法二(没试过):
把hive-builtins包上传到提示的hdfs路径(我这里是/home/fatkun/hive-0.10.0-cdh4.3.0/lib/)
$ hadoop fs -mkdir /home/fatkun/hive-0.10.0-cdh4.3.0/lib/
$ hadoop fs -put $HIVE_HOME/lib/hive-builtins-*.jar /home/fatkun/hive-0.10.0-cdh4.3.0/lib/

参考

FileNotFoundException for hive/lib/hive-builtins-0.9.0.jar in Hive

updatedupdated2024-11-302024-11-30