jenkinsci/jenkins · error · IllegalStateException

Found no instances of ${type.getName()} registered

Error message

Found no instances of ${type.getName()} registered

What it means

Thrown by ExtensionList.lookupFirst (non-unit-test branch) when no instance of the requested type is registered at all. lookupFirst returns the highest-ordinal instance or throws; in unit-test mode it adds a hint about annotation processors and IDE runners. The non-test path is a hard failure indicating the type was never loaded.

Source

Thrown at core/src/main/java/hudson/ExtensionList.java:483

     * Equivalent to {@code ExtensionList.lookup(type).get(0)} if there is at least one instance,
     * and throws an {@link IllegalStateException} otherwise if no instance could be found.
     *
     * @param type The type to look up.
     * @return the singleton instance of the given type in its list.
     * @throws IllegalStateException if there are no instances
     *
     * @since 2.435
     */
    public static @NonNull <U> U lookupFirst(Class<U> type) {
        var all = lookup(type);
        if (!all.isEmpty()) {
            return all.getFirst();
        } else {
            if (Main.isUnitTest) {
                throw new IllegalStateException("Found no instances of " + type.getName() +
                        " registered (possible annotation processor issue); try using `mvn clean test -Dtest=…` rather than an IDE test runner");
            } else {
                throw new IllegalStateException("Found no instances of " + type.getName() + " registered");
            }
        }
    }

    /**
     * @deprecated No longer does anything.
     */
    @Deprecated
    public static void clearLegacyInstances() {
    }

    private static final Logger LOGGER = Logger.getLogger(ExtensionList.class.getName());
}

View on GitHub (pinned to 2e228ff40b)

Solutions

  1. Verify the type has an @Extension registration and its plugin is enabled.
  2. Guard against absence: use lookup(type) and check isEmpty() before use.
  3. Ensure the call is not made during startup/shutdown when the registry is incomplete.
  4. If in a plugin, confirm the extension is listed in the generated META-INF/annotations index.

Example fix

// before
var s = ExtensionList.lookupFirst(MyService.class); // throws if none
// after
var list = ExtensionList.lookup(MyService.class);
MyService s = list.isEmpty() ? null : list.get(0);
Defensive patterns

Strategy: validation

Validate before calling

ExtensionList<MyService> all = ExtensionList.lookup(MyService.class);
if (all.isEmpty()) {
    // not registered — handle absence gracefully
} else {
    MyService s = all.get(0);
}

Type guard

static boolean isRegistered(Class<?> type) {
    return !ExtensionList.lookup(type).isEmpty();
}

Try / catch

try {
    var s = ExtensionList.lookupFirst(MyService.class);
} catch (IllegalStateException e) {
    // 'Found no instances' — provide a default or skip the feature
}

Prevention

When it happens

Trigger: Calling lookupFirst for a type with zero registered instances at runtime; calling before Jenkins finished loading extensions; the type is not annotated @Extension or its plugin is disabled; Jenkins.getInstanceOrNull() is null during shutdown.

Common situations: Extension point never registered; plugin providing it disabled or failed to start; called during early bootstrap before components load; calling after shutdown teardown.

Related errors


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