prestodb/presto · error · ClassNotFoundException

Class of function {name} not found

Error message

Class of function {name} not found

What it means

StaticHiveFunctionRegistry.getClass() resolves a Hive function's implementing Java class via the Hive metastore's function info (FunctionInfo). If the function name cannot be found in the registry (SemanticException) or the lookup yields nothing usable (NullPointerException), it rethrows as ClassNotFoundException, meaning no class implements that function name in this namespace.

Source

Thrown at presto-hive-function-namespace/src/main/java/com/facebook/presto/hive/functions/StaticHiveFunctionRegistry.java:44

        implements HiveFunctionRegistry
{
    private final ClassLoader classLoader;

    @Inject
    public StaticHiveFunctionRegistry(@ForHiveFunction ClassLoader classLoader)
    {
        this.classLoader = requireNonNull(classLoader, "classLoader is null");
    }

    @Override
    public Class<?> getClass(QualifiedObjectName name)
            throws ClassNotFoundException
    {
        try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
            return getFunctionInfo(name.getObjectName()).getFunctionClass();
        }
        catch (SemanticException | NullPointerException e) {
            throw new ClassNotFoundException("Class of function " + name + " not found", e);
        }
    }
}

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Verify the function name and catalog/namespace are correct and that the function is registered in StaticHiveFunctionRegistry.
  2. Check whether the Presto hive-functions build actually ships that function (version compatibility).
  3. If relying on a metastore-registered function, confirm the FunctionInfo and its class are present and loadable with the configured classloader.
  4. Catch ClassNotFoundException at the call site and surface a friendly FUNCTION_NOT_FOUND error to the user.

Example fix

// before
Class<?> cls = registry.getClass(functionName, classLoader);
// after
try {
    Class<?> cls = registry.getClass(functionName, classLoader);
} catch (ClassNotFoundException e) {
    throw new PrestoException(FUNCTION_NOT_FOUND, "Unknown Hive function: " + functionName, e);
}
Defensive patterns

Strategy: try-catch

Validate before calling

// confirm function exists before class lookup
// e.g. check registry.getFunctionInfo(name) semantics via a presence check or list of known functions

Try / catch

try {
    Class<?> cls = registry.getClass(functionName, classLoader);
} catch (ClassNotFoundException e) {
    throw new PrestoException(FUNCTION_NOT_FOUND, "Hive function not registered: " + functionName, e);
}

Prevention

When it happens

Trigger: Requesting the function class for a QualifiedObjectName whose function is absent from StaticHiveFunctionRegistry's functionInfos map (getFunctionInfo throws SemanticException.FUNCTION_NOT_FOUND), or whose registered info has no function class (NPE).

Common situations: Queries using a Hive function name that is misspelled, not registered in this Presto version, or whose Hive metastore registration is incomplete; version drift where a function exists in Hive but not in Presto's static registry.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/53e1763011cc16e2. Report an issue: GitHub.