apache/pulsar · error · IllegalStateException

No dependencies are registered for function ${fid}

Error message

No dependencies are registered for function ${fid}

What it means

FunctionCacheManagerImpl.getClassLoader(fid) looks up the FunctionCacheEntry for the given function ID; this IllegalStateException is thrown when no entry exists — i.e. no jar dependencies were ever registered for that function ID on this worker, so there is no classloader to return.

Source

Thrown at pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/functioncache/FunctionCacheManagerImpl.java:58

    public FunctionCacheManagerImpl(ClassLoader rootClassLoader) {
        this.cacheFunctions = new ConcurrentHashMap<>();
        this.rootClassLoader = rootClassLoader;
    }

    Map<String, FunctionCacheEntry> getCacheFunctions() {
        return cacheFunctions;
    }

    @Override
    public ClassLoader getClassLoader(String fid) {
        if (fid == null) {
            throw new IllegalArgumentException("FunctionID not set");
        }

        synchronized (cacheFunctions) {
            FunctionCacheEntry entry = cacheFunctions.get(fid);
            if (entry == null) {
                throw new IllegalStateException("No dependencies are registered for function " + fid);
            }
            return entry.getClassLoader();
        }
    }

    @Override
    public void registerFunctionInstance(String fid,
                                         String eid,
                                         List<String> requiredJarFiles,
                                         List<URL> requiredClasspaths)
            throws IOException {
        if (fid == null) {
            throw new NullPointerException("FunctionID not set");
        }

        synchronized (cacheFunctions) {
            FunctionCacheEntry entry = cacheFunctions.get(fid);

View on GitHub (pinned to 820761864e)

Solutions

  1. Register the function's dependencies first via registerFunctionInstance(...) / registerFunctionInstanceWithArchive(...) before requesting the classloader.
  2. Restart the affected function instance so it re-registers with the manager after a worker restart.
  3. Verify the fid used for lookup matches the one used at registration (no typo/normalization differences).

Example fix

// before
ClassLoader cl = cacheManager.getClassLoader(fid); // nothing registered yet
// after
FunctionCacheEntry entry = cacheManager.getFunctionCacheEntry(tenant, namespace, name, null, null, null, null, null, null, false, null);
cacheManager.registerFunctionInstance(fid, entry, jarFiles, classpaths, eid, ...);
ClassLoader cl = cacheManager.getClassLoader(fid);
Defensive patterns

Strategy: try-catch

Validate before calling

FunctionCacheEntry entry = cacheManager.getFunctionCacheEntry(tenant, namespace, name);
if (entry == null) {
    // register dependencies before calling getClassLoader
    cacheManager.registerFunctionInstance(fid, entry, jarFiles, classpaths, eid, null, null, null, 0L, null);
}

Try / catch

try {
    ClassLoader cl = cacheManager.getClassLoader(fid);
} catch (IllegalStateException e) {
    if (e.getMessage().startsWith("No dependencies are registered")) {
        // re-register dependencies (e.g. after worker restart) then retry once
        registerDependencies(fid);
        ClassLoader cl = cacheManager.getClassLoader(fid);
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: Calling getClassLoader(fid) for a fid that was never passed to registerFunctionInstance/registerFunctionInstanceWithArchive, or after the entry was removed by removeFunction / cache eviction while the instance is still running.

Common situations: A worker restarted and its in-memory function cache is empty while old function instances still request classloaders; ordering bug where the classloader is fetched before registering dependencies; function was deleted/updated concurrently and the cache entry was removed; fid mismatch (typo or different ID format) between registration and lookup.

Related errors


AI-assisted analysis of apache/pulsar@820761864e (2026-09-06). Data as JSON: /api/errors/c513c69feb770256. Report an issue: GitHub.