apache/hadoop · critical · ServerException

S02

S02

Error message

[{0}] is not a directory

What it means

Server.verifyDir() first checks existence (S01) and then that the path is a directory; if a regular file (or anything non-directory) occupies the path, it throws ServerException S02('[<path>] is not a directory'). Like S01, this aborts HttpFS startup at construction time.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/server/Server.java:403

    setStatus(status);
    log.info("Server [{}] started!, status [{}]", name, status);
  }

  /**
   * Verifies the specified directory exists.
   *
   * @param dir directory to verify it exists.
   *
   * @throws ServerException thrown if the directory does not exist or it the
   * path it is not a directory.
   */
  private void verifyDir(String dir) throws ServerException {
    File file = new File(dir);
    if (!file.exists()) {
      throw new ServerException(ServerException.ERROR.S01, dir);
    }
    if (!file.isDirectory()) {
      throw new ServerException(ServerException.ERROR.S02, dir);
    }
  }

  /**
   * Initializes Log4j logging.
   *
   * @throws ServerException thrown if Log4j could not be initialized.
   */
  protected void initLog() throws ServerException {
    verifyDir(logDir);
    LogManager.resetConfiguration();
    File log4jFile = new File(configDir, name + "-log4j.properties");
    if (log4jFile.exists()) {
      PropertyConfigurator.configureAndWatch(log4jFile.toString(), 10 * 1000); //every 10 secs
      log = LoggerFactory.getLogger(Server.class);
    } else {
      Properties props = new Properties();
      try {

View on GitHub (pinned to 2add963021)

Solutions

  1. Inspect the path from the message: ls -ld <path> — if it is a file, remove or relocate it and mkdir -p the directory.
  2. Correct the owning property (httpfs.home.dir/config.dir/log.dir/temp.dir) to the intended directory.
  3. Fix provisioning scripts to use mkdir -p, never touch, for directory paths.

Example fix

# before
$ ls -ld /var/log/hadoop-httpfs
-rw-r--r-- 1 httpfs hadoop 0 ... /var/log/hadoop-httpfs   # a file

# after
$ rm /var/log/hadoop-httpfs
$ mkdir -p /var/log/hadoop-httpfs && chown httpfs:hadoop /var/log/hadoop-httpfs
Defensive patterns

Strategy: validation

Validate before calling

# pre-start: every configured dir must be a directory
for d in "$HTTPFS_HOME" "$HTTPFS_CONFIG" "$HTTPFS_LOG" "$HTTPFS_TEMP"; do
  [ -z "$d" ] && continue
  [ -d "$d" ] || { echo "FATAL: $d is not a directory"; exit 1; }
done

Prevention

When it happens

Trigger: httpfs.log.dir=/var/log/hadoop-httpfs where hadoop-httpfs is a log FILE created earlier by a redirect; a config dir path occupied by a tarball or marker file; a bind-mounted file where a directory mount was intended; scripts that 'touch' paths to pre-create them.

Common situations: Operators pre-creating paths with touch instead of mkdir -p; log directories accidentally created as files by init scripts ('> /var/log/x'); Docker volumes mapping a file onto a path the server expects to be a directory.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/81217dc355a4f24a. Report an issue: GitHub.