apache/hadoop · error · NotInMountpointException
getServerDefaults on empty path is invalid
Error message
getServerDefaults on empty path is invalid
What it means
ViewFileSystem (viewfs) is a client-side mount table that forwards each operation to the backing FileSystem of the mount point that owns the path. It has no single underlying server, so the no-argument getServerDefaults() (and the sibling no-arg getDefaultBlockSize()/getDefaultReplication()) cannot return meaningful values and always throws NotInMountpointException, an UnsupportedOperationException. Server defaults only exist per target cluster, so the path-aware overloads must be used instead.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java:963
throw new RuntimeException(errMsg, ex);
}
}
return fsMap;
}
@Override
public long getDefaultBlockSize() {
throw new NotInMountpointException("getDefaultBlockSize");
}
@Override
public short getDefaultReplication() {
throw new NotInMountpointException("getDefaultReplication");
}
@Override
public FsServerDefaults getServerDefaults() throws IOException {
throw new NotInMountpointException("getServerDefaults");
}
@Override
public long getDefaultBlockSize(Path f) {
try {
InodeTree.ResolveResult<FileSystem> res =
fsState.resolve(getUriPath(f), true);
return res.targetFileSystem.getDefaultBlockSize(res.remainingPath);
} catch (FileNotFoundException e) {
throw new NotInMountpointException(f, "getDefaultBlockSize");
} catch (IOException e) {
throw new RuntimeException("Not able to initialize fs in "
+ " getDefaultBlockSize for path " + f + " with exception", e);
}
}
@Override
public short getDefaultReplication(Path f) {View on GitHub (pinned to 2add963021)
Solutions
- Switch to the path-aware overloads on a path that resolves into a mount point: fs.getServerDefaults(new Path("/mounted/dir")), fs.getDefaultBlockSize(path), fs.getDefaultReplication(path)
- Add a root mount so every path resolves: set fs.viewfs.mounttable.default.linkMergeSlash=hdfs://nameservice1/ in core-site.xml
- If only default values are needed, read them from the target cluster config (dfs.blocksize, dfs.replication) or from getServerDefaults() of the target HDFS FileSystem instead of the viewfs handle
- As a last resort catch NotInMountpointException (or its parent UnsupportedOperationException) and fall back to known cluster defaults
Example fix
// before
FileSystem fs = FileSystem.get(new URI("viewfs://cluster"), conf);
long bs = fs.getDefaultBlockSize(); // throws NotInMountpointException
// after
FileSystem fs = FileSystem.get(new URI("viewfs://cluster"), conf);
long bs = fs.getDefaultBlockSize(new Path("/data/somefile")); // path inside a mount point
// or, for cluster-wide defaults, ask the target FS directly:
// FsServerDefaults d = fs.getServerDefaults(new Path("/data")); Defensive patterns
Strategy: try-catch
Validate before calling
// No-arg server-default calls on viewfs are invalid by design; there is nothing to validate.
// Route the call through a mounted path instead:
Path mounted = new Path("viewfs://cluster/data");
FileSystem fs = mounted.getFileSystem(conf);
FsServerDefaults d = fs.getServerDefaults(mounted); Try / catch
import org.apache.hadoop.fs.viewfs.NotInMountpointException;
try {
long bs = fs.getDefaultBlockSize();
} catch (NotInMountpointException | UnsupportedOperationException e) {
// viewfs has no cluster-wide defaults; use target-cluster config
long bs = conf.getLongBytes("dfs.blocksize", 128L * 1024 * 1024);
} Prevention
- Never call the no-arg getDefaultBlockSize/getDefaultReplication/getServerDefaults on a FileSystem you did not create from a concrete HDFS URI
- Wrap default-FS access in a utility that detects viewfs:// schemes and delegates to path-aware overloads
- Add linkMergeSlash to the mount table so root-level default queries succeed during migrations
When it happens
Trigger: Calling fs.getServerDefaults(), fs.getDefaultBlockSize(), or fs.getDefaultReplication() on a FileSystem whose URI is viewfs://<cluster> (e.g. new Path("viewfs://cluster/").getFileSystem(conf)). Typical producers are framework code (distcp, job submission, Hive/Spark writers) that derives default block size or replication from the default FileSystem when fs.defaultFS points at viewfs.
Common situations: fs.defaultFS switched to viewfs://cluster during an HDFS federation/router migration while tools still assume a plain HDFS handle; mount table without linkMergeSlash so even the root path resolves nowhere; old client code using the deprecated no-arg methods.
Related errors
- getServerDefaults on path `<f>' is not within a mount point
- ViewFs: Non absolute mount name in config:{src}
- Path {nextInode.fullPath} already exists as link
- Path {strB} already exists as dir; cannot create link here
- Unexpected mount table link entry '{key}'. Use linkMergeSlas
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/671e582a11ee24ee.
Report an issue: GitHub.