prestodb/presto · critical · RuntimeException

Failed to build plugin classloaders

Error message

Failed to build plugin classloaders

What it means

RouterPluginManager.buildPluginClassLoaders wraps any exception raised while constructing plugin classloaders (locating plugin dirs, building the SPI/URL classloader) in a RuntimeException with message 'Failed to build plugin classloaders', preserving the cause.

Source

Thrown at presto-router/src/main/java/com/facebook/presto/router/RouterPluginManager.java:163

        {
            pluginManager.installRouterPlugin(plugin);
        }
    }

    private List<PluginManagerUtil.PluginClassLoaderHandle> createPluginClassLoaders()
    {
        try {
            return PluginManagerUtil.buildClassLoaders(
                    installedPluginsDir,
                    plugins,
                    resolver,
                    SPI_PACKAGES,
                    null,
                    SERVICES_FILE,
                    getClass().getClassLoader());
        }
        catch (Exception e) {
            throw new RuntimeException("Failed to build plugin classloaders", e);
        }
    }
}

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Inspect the wrapped cause in the stack trace to find the failing jar or services file
  2. Verify the plugin directory exists, is readable, and contains a well-formed META-INF/services entry
  3. Reinstall/redeploy the plugin cleanly (remove partial installs and reinstall the plugin archive)

Example fix

// before: plugin/router/my-plugin/ missing META-INF/services/com.facebook.presto.spi.RouterPluginFactory
// after: include the services file (or the plugin jar that provides it) in the plugin dir
Defensive patterns

Strategy: try-catch

Validate before calling

Path pluginDir = Paths.get("plugin/router/my-plugin");
if (!Files.isDirectory(pluginDir) || !Files.isReadable(pluginDir)) {
    throw new IllegalStateException("Plugin dir missing or unreadable: " + pluginDir);
}

Try / catch

try { pluginManager.installRouterPlugin(plugin); } catch (RuntimeException e) {
    if ("Failed to build plugin classloaders".equals(e.getMessage())) {
        log.error("Plugin classloader failure; cause=" + e.getCause());
        // remove/repair the offending plugin directory before retry
    } else throw e;
}

Prevention

When it happens

Trigger: Plugin directory missing/unreadable, a malformed or duplicated SPI services file, or any Exception from the classloader construction for router SPI packages during plugin installation.

Common situations: Broken or incomplete plugin installation under plugin/router/; wrong file permissions after deployment; corrupt jar in the plugin directory; SERVICES_FILE resource missing from a plugin.

Related errors


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