读书人

HDFS 抛出异常 (java.io.IOException:

发布时间: 2012-12-20 09:53:21 作者: rapoo

HDFS 抛出错误 (java.io.IOException: config())

?

DEBUG [main] Configuration.<init>(211) | java.io.IOException: config()

at org.apache.hadoop.conf.Configuration.<init>(Configuration.java:211)

at com.netqin.hdfs.MyHdfs.isExists(MyHdfs.java:20)

at com.netqin.hdfs.MyHdfs.main(MyHdfs.java:41)

?

在客户端使用API访问HDFS的时候保了一个这样的错误。

?

通过定位代码:

?

?

??/** A new configuration where the behavior of reading from the default?

?? * resources can be turned off.

?? *?

?? * If the parameter {@code loadDefaults} is false, the new instance

?? * will not load resources from the default files.?

?? * @param loadDefaults specifies whether to load from the default files

?? */

??public Configuration(boolean loadDefaults) {

?? ?this.loadDefaults = loadDefaults;

?? ?if (LOG.isDebugEnabled()) {

?? ? ?LOG.debug(StringUtils.stringifyException(new IOException("config()")));

?? ?}

?? ?synchronized(Configuration.class) {

?? ? ?REGISTRY.put(this, null);

?? ?}

??}

?

原来是标红的这一行抛出的错误,原因就是HDFS不允许在log4j中使用DEBUG输出日志。如果有则抛出了错误,不过这个错误太不明显了,让人搞得莫名其妙。

?

?

解决办法:

把Log4j文件

# 本文件为日志显示控制文件

log4j.rootCategory=DEBUG,stdout,file

?

改为

log4j.rootCategory=ERROR,stdout,file

?

?

?

1 楼 linbin19851010 2011-07-15 兄弟,没什么好说的了.太感谢了.这解答真是太及时了啊.完成解决了我的问题!

读书人网 >编程

热点推荐