---
title: "HDFS 抛出错误 (java.io.IOException: config())"
author: "xiaobian"
date: "2011-04-07T14:56:45Z"
tags: []
categories: ["编程语言"]
slug: "hdfs-java-io-ioexception-config"
draft: false
lastmod: "2011-04-07T14:57:58Z"
id: 990608
url: "https://jimi68.iteye.com/blog/990608"
---

DEBUG \[main] Configuration.&lt;init&gt;(211) | java.io.IOException: config()

at org.apache.hadoop.conf.Configuration.&lt;init&gt;(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