jenkinsci/jenkins · error · Exception

Cannot find the plugin instance: {0}

Error message

Cannot find the plugin instance: {0}

What it means

Exception thrown by getPluginOrFail() when the PluginInstanceStore does not contain a Plugin instance for this PluginWrapper. This means the plugin's Java instance (the Plugin subclass) was never registered — the plugin loaded structurally (classloader, manifest) but its Plugin.start()/onLoad() either failed or never ran, or the PluginInstanceStore was not populated.

Source

Thrown at core/src/main/java/hudson/PluginWrapper.java:619

    }

    /**
     * Gets the instance of {@link Plugin} contributed by this plugin.
     * @return Plugin instace or {@code null} if it is not present in the plugin instance store.
     */
    public @CheckForNull Plugin getPlugin() {
        PluginInstanceStore pis = Jenkins.lookup(PluginInstanceStore.class);
        return pis != null ? pis.store.get(this) : null;
    }

    /**
     * Gets the instance of {@link Plugin} contributed by this plugin.
     * @throws Exception no plugin in the {@link PluginInstanceStore}
     */
    public @NonNull Plugin getPluginOrFail() throws Exception {
        Plugin plugin = getPlugin();
        if (plugin == null) {
            throw new Exception("Cannot find the plugin instance: " + shortName);
        }
        return plugin;
    }

    /**
     * Gets the URL that shows more information about this plugin.
     * @return
     *      null if this information is unavailable.
     * @since 1.283
     */
    @Exported
    public String getUrl() {
        // first look in update center metadata
        List<UpdateSite.Plugin> siteMetadataList = getInfoFromAllSites();
        String firstSiteUrl = null;
        if (!siteMetadataList.isEmpty()) {
            firstSiteUrl = siteMetadataList.getFirst().wiki;
            if (allUrlsMatch(firstSiteUrl, siteMetadataList)) {

View on GitHub (pinned to 2e228ff40b)

Solutions

  1. Check pluginWrapper.getPlugin() for null before calling getPluginOrFail().
  2. Review Jenkins logs for errors during the plugin's onLoad()/start() lifecycle.
  3. Ensure the plugin's Plugin subclass is properly annotated and instantiated by the extension framework.
  4. Restart Jenkins if the plugin is in a partially loaded state.

Example fix

// before
Plugin plugin = wrapper.getPluginOrFail();
plugin.doSomething();

// after
Plugin plugin = wrapper.getPlugin();
if (plugin == null) {
    listener.getLogger().println("Plugin " + wrapper.getShortName() + " not initialized.");
    return;
}
plugin.doSomething();
Defensive patterns

Strategy: validation

Validate before calling

Plugin plugin = wrapper.getPlugin();
if (plugin == null) {
    throw new IllegalStateException("Plugin instance for " + wrapper.getShortName() + " not initialized; check Jenkins logs for startup errors.");
}

Type guard

public static boolean isPluginInitialized(PluginWrapper pw) {
    return pw.getPlugin() != null;
}

Try / catch

try {
    Plugin plugin = wrapper.getPluginOrFail();
    plugin.doSomething();
} catch (Exception e) {
    if (e.getMessage().contains("Cannot find the plugin instance")) {
        listener.getLogger().println("Plugin " + wrapper.getShortName() + " not initialized; skipping.");
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: Calling pluginWrapper.getPluginOrFail() when the plugin's Plugin instance has not been registered in the PluginInstanceStore — typically during early initialization before the plugin's start() completes, or after a failed initialization.

Common situations: A plugin whose constructor or onLoad() threw an exception (so the instance was never stored), calling postInitialize before the plugin is fully started, or accessing the plugin instance during a partial/failed load cycle.

Related errors


AI-assisted analysis of jenkinsci/jenkins@2e228ff40b (2026-08-14). Data as JSON: /api/errors/e712937ebef14b62. Report an issue: GitHub.