{"record":{"id":"53e1763011cc16e2","repo":"prestodb/presto","slug":"class-of-function-name-not-found","errorCode":null,"errorMessage":"Class of function {name} not found","messagePattern":"Class of function (.+?) not found","errorType":"exception","errorClass":"ClassNotFoundException","httpStatus":null,"severity":"error","filePath":"presto-hive-function-namespace/src/main/java/com/facebook/presto/hive/functions/StaticHiveFunctionRegistry.java","lineNumber":44,"sourceCode":"        implements HiveFunctionRegistry\n{\n    private final ClassLoader classLoader;\n\n    @Inject\n    public StaticHiveFunctionRegistry(@ForHiveFunction ClassLoader classLoader)\n    {\n        this.classLoader = requireNonNull(classLoader, \"classLoader is null\");\n    }\n\n    @Override\n    public Class<?> getClass(QualifiedObjectName name)\n            throws ClassNotFoundException\n    {\n        try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {\n            return getFunctionInfo(name.getObjectName()).getFunctionClass();\n        }\n        catch (SemanticException | NullPointerException e) {\n            throw new ClassNotFoundException(\"Class of function \" + name + \" not found\", e);\n        }\n    }\n}\n","sourceCodeStart":26,"sourceCodeEnd":48,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive-function-namespace/src/main/java/com/facebook/presto/hive/functions/StaticHiveFunctionRegistry.java#L26-L48","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Verify the function name and catalog/namespace are correct and that the function is registered in StaticHiveFunctionRegistry.","Check whether the Presto hive-functions build actually ships that function (version compatibility).","If relying on a metastore-registered function, confirm the FunctionInfo and its class are present and loadable with the configured classloader.","Catch ClassNotFoundException at the call site and surface a friendly FUNCTION_NOT_FOUND error to the user."],"exampleFix":"// before\nClass<?> cls = registry.getClass(functionName, classLoader);\n// after\ntry {\n    Class<?> cls = registry.getClass(functionName, classLoader);\n} catch (ClassNotFoundException e) {\n    throw new PrestoException(FUNCTION_NOT_FOUND, \"Unknown Hive function: \" + functionName, e);\n}","handlingStrategy":"try-catch","validationCode":"// confirm function exists before class lookup\n// e.g. check registry.getFunctionInfo(name) semantics via a presence check or list of known functions","typeGuard":null,"tryCatchPattern":"try {\n    Class<?> cls = registry.getClass(functionName, classLoader);\n} catch (ClassNotFoundException e) {\n    throw new PrestoException(FUNCTION_NOT_FOUND, \"Hive function not registered: \" + functionName, e);\n}","preventionTips":["Verify the function name spelling and namespace before lookup.","Confirm the function is shipped/registered in your Presto version's StaticHiveFunctionRegistry.","Ensure the Hive function jar and its class are on the configured plugin classloader path."],"tags":["hive","function-not-found","classpath","classloader"],"backgroundTag":"function-not-found","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}