欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Hive源码分析(二) Eclipse调试Hive源码报does not have a scheme错误解决

程序员文章站 2022-04-29 13:51:19
...

   本博客属原创文章,转载请注明出处:http://guoyunsky.iteye.com/blog/1177909    

    欢迎加入Hadoop超级群: 180941958   

     终于可以调试Hive源码了.首当其冲的就报了这个错误:

FAILED: Error in metadata: java.lang.IllegalArgumentException: URI:  does not have a scheme
2011-09-22 11:54:57,890 ERROR [main] session.SessionState$LogHelper(343): FAILED: Error in metadata: java.lang.IllegalArgumentException: URI:  does not have a scheme
org.apache.hadoop.hive.ql.metadata.HiveException: java.lang.IllegalArgumentException: URI:  does not have a scheme
	at org.apache.hadoop.hive.ql.metadata.Hive.getDatabase(Hive.java:1028)
	at org.apache.hadoop.hive.ql.metadata.Hive.databaseExists(Hive.java:1013)
	at org.apache.hadoop.hive.ql.exec.DDLTask.showTables(DDLTask.java:1691)
	at org.apache.hadoop.hive.ql.exec.DDLTask.execute(DDLTask.java:289)
	at org.apache.hadoop.hive.ql.exec.Task.executeTask(Task.java:130)
	at org.apache.hadoop.hive.ql.exec.TaskRunner.runSequential(TaskRunner.java:57)
	at org.apache.hadoop.hive.ql.Driver.launchTask(Driver.java:1063)
	at org.apache.hadoop.hive.ql.Driver.execute(Driver.java:900)
	at org.apache.hadoop.hive.ql.Driver.run(Driver.java:748)
	at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:164)
	at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:241)
	at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:456)
Caused by: java.lang.IllegalArgumentException: URI:  does not have a scheme
	at org.apache.hadoop.hive.metastore.HiveMetaStoreClient.<init>(HiveMetaStoreClient.java:127)
	at org.apache.hadoop.hive.ql.metadata.Hive.createMetaStoreClient(Hive.java:1855)
	at org.apache.hadoop.hive.ql.metadata.Hive.getMSC(Hive.java:1865)
	at org.apache.hadoop.hive.ql.metadata.Hive.getDatabase(Hive.java:1024)
	... 11 more

  然后启动后在控制台也收到这样一条Log:hive-log4j.properties not found

 

    源码调下来,发现是Hive在加载配置文件如hive-default.xml,hive-log4j.properties时采用这种方法:

 private ClassLoader classLoader;
  {
    classLoader = Thread.currentThread().getContextClassLoader();
    if (classLoader == null) {
      classLoader = Configuration.class.getClassLoader();
    }
  }

   然后获取hive-default.xml等是采用如下代码:

URL hconfurl = getClassLoader().getResource("hive-default.xml");

   这样在jar中运行是没有问题的,但放到Eclipse里运行的话,获取的路径就会有出路了.现在来验证下:

 

package com.guoyun.hive.study.basic;

public class PrintSourcePath {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ClassLoader loader=Thread.currentThread().getContextClassLoader();
		System.out.println("Run path:"+loader.getResource("").getPath());
		// hive-default.xml
		System.out.println("hive-default.xml path:"+loader.getResource("hive-default.xml").getPath());

	}

}

    控制台输出如下:

    Run path:/home/hadoop/workspace/hive-0.7.0/bin/
    Exception in thread "main" java.lang.NullPointerException
    at com.guoyun.hive.study.basic.PrintSourcePath.main(PrintSourcePath.java:12)

   在获取hive-default.xml文件源时报来空指针异常,现在将hive_home/conf下到文件拷到hive/bin下,再运行这个类就不会报错了,我的运行结果如下:

    Run path:/home/hadoop/workspace/hive-0.7.0/bin/

    hive-default.xml path:/home/hadoop/workspace/hive-0.7.0/bin/hive-default.xml

 

  之后再来调试Hive源码,Log:hive-log4j.properties not found已经不出现了。同时也没这个错误来。该问题解决!但接下来又发生了其他错误。。。一步步解决吧。

 

更多技术文章、感悟、分享、勾搭,请用微信扫描:

Hive源码分析(二) Eclipse调试Hive源码报does not have a scheme错误解决
            
    
    博客分类: HiveHadoop