apache/hadoop · error · IllegalArgumentException

File name can't be empty string

Error message

File name can't be empty string

What it means

JobResourceUploader.copyLog4jPropertyFile reads mapreduce.job.log4j-properties-file (MRJobConfig.MAPREDUCE_JOB_LOG4J_PROPERTIES_FILE) via validateFilePath. A null value means 'not set' and returns null, but an explicitly empty string throws IllegalArgumentException("File name can't be empty string") — the property was set to '' rather than left unset.

Source

Thrown at hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/JobResourceUploader.java:872

  }

  /**
   * takes input as a path string for file and verifies if it exist. It defaults
   * for file:/// if the files specified do not have a scheme. it returns the
   * paths uri converted defaulting to file:///. So an input of /home/user/file1
   * would return file:///home/user/file1
   * 
   * @param file
   * @param conf
   * @return
   */
  private String validateFilePath(String file, Configuration conf)
      throws IOException {
    if (file == null) {
      return null;
    }
    if (file.isEmpty()) {
      throw new IllegalArgumentException("File name can't be empty string");
    }
    String finalPath;
    URI pathURI;
    try {
      pathURI = new URI(file);
    } catch (URISyntaxException e) {
      throw new IllegalArgumentException(e);
    }
    Path path = new Path(pathURI);
    if (pathURI.getScheme() == null) {
      FileSystem localFs = FileSystem.getLocal(conf);
      // default to the local file system
      // check if the file exists or not first
      localFs.getFileStatus(path);
      finalPath =
          path.makeQualified(localFs.getUri(), localFs.getWorkingDirectory())
              .toString();
    } else {

View on GitHub (pinned to 2add963021)

Solutions

  1. Remove the property entirely instead of setting it to empty: drop the -D flag or the <property> element
  2. In code, only set the key when the value is non-empty: if (path != null && !path.isEmpty()) conf.set(key, path)
  3. Guard templates with defaults: ${log4jprops:file:///etc/log4j.properties} style fallback to a real path
  4. Unset defensively before submit: conf.unset("mapreduce.job.log4j-properties-file") when blank

Example fix

// before
String props = getArgOrDefault("log4jprops", ""); // defined but empty
conf.set(MRJobConfig.MAPREDUCE_JOB_LOG4J_PROPERTIES_FILE, props); // -> 'File name can't be empty string'

// after
String props = getArg("log4jprops");
if (props != null && !props.isEmpty()) {
  conf.set(MRJobConfig.MAPREDUCE_JOB_LOG4J_PROPERTIES_FILE, props);
}
Defensive patterns

Strategy: validation

Validate before calling

// only set the property when it carries a real value
String props = getOptional("log4jprops");
if (props == null || props.isEmpty()) {
  conf.unset(MRJobConfig.MAPREDUCE_JOB_LOG4J_PROPERTIES_FILE);
} else {
  conf.set(MRJobConfig.MAPREDUCE_JOB_LOG4J_PROPERTIES_FILE, props);
}

Prevention

When it happens

Trigger: Passing -D mapreduce.job.log4j-properties-file= (empty value) on the command line; workflow tools that always write the key even when the user left it blank (conf.set(key, varOrDefault) with an empty default); templated XML where the placeholder resolves to empty.

Common situations: Oozie/Workflow <configuration> sections generated from optional parameters; shell scripts doing conf.set when a variable is defined-but-empty; migration of old mapred.system.log.properties? setups that defaulted to ''.

Related errors


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