{"record":{"id":"459ed143ef1ac2af","repo":"jenkinsci/jenkins","slug":"found-no-instances-of-type-getname-registered","errorCode":null,"errorMessage":"Found no instances of ${type.getName()} registered","messagePattern":"Found no instances of (.+?) registered","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/hudson/ExtensionList.java","lineNumber":483,"sourceCode":"     * Equivalent to {@code ExtensionList.lookup(type).get(0)} if there is at least one instance,\n     * and throws an {@link IllegalStateException} otherwise if no instance could be found.\n     *\n     * @param type The type to look up.\n     * @return the singleton instance of the given type in its list.\n     * @throws IllegalStateException if there are no instances\n     *\n     * @since 2.435\n     */\n    public static @NonNull <U> U lookupFirst(Class<U> type) {\n        var all = lookup(type);\n        if (!all.isEmpty()) {\n            return all.getFirst();\n        } else {\n            if (Main.isUnitTest) {\n                throw new IllegalStateException(\"Found no instances of \" + type.getName() +\n                        \" registered (possible annotation processor issue); try using `mvn clean test -Dtest=…` rather than an IDE test runner\");\n            } else {\n                throw new IllegalStateException(\"Found no instances of \" + type.getName() + \" registered\");\n            }\n        }\n    }\n\n    /**\n     * @deprecated No longer does anything.\n     */\n    @Deprecated\n    public static void clearLegacyInstances() {\n    }\n\n    private static final Logger LOGGER = Logger.getLogger(ExtensionList.class.getName());\n}\n","sourceCodeStart":465,"sourceCodeEnd":497,"githubUrl":"https://github.com/jenkinsci/jenkins/blob/2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc/core/src/main/java/hudson/ExtensionList.java#L465-L497","documentation":"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.","triggerScenarios":"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.","commonSituations":"Extension point never registered; plugin providing it disabled or failed to start; called during early bootstrap before components load; calling after shutdown teardown.","solutions":["Verify the type has an @Extension registration and its plugin is enabled.","Guard against absence: use lookup(type) and check isEmpty() before use.","Ensure the call is not made during startup/shutdown when the registry is incomplete.","If in a plugin, confirm the extension is listed in the generated META-INF/annotations index."],"exampleFix":"// before\nvar s = ExtensionList.lookupFirst(MyService.class); // throws if none\n// after\nvar list = ExtensionList.lookup(MyService.class);\nMyService s = list.isEmpty() ? null : list.get(0);","handlingStrategy":"validation","validationCode":"ExtensionList<MyService> all = ExtensionList.lookup(MyService.class);\nif (all.isEmpty()) {\n    // not registered — handle absence gracefully\n} else {\n    MyService s = all.get(0);\n}","typeGuard":"static boolean isRegistered(Class<?> type) {\n    return !ExtensionList.lookup(type).isEmpty();\n}","tryCatchPattern":"try {\n    var s = ExtensionList.lookupFirst(MyService.class);\n} catch (IllegalStateException e) {\n    // 'Found no instances' — provide a default or skip the feature\n}","preventionTips":["Use lookup(type) + isEmpty() guard when absence is a valid runtime state.","Confirm the type is @Extension-annotated and its plugin is enabled.","Avoid lookups during shutdown when the registry is being torn down."],"tags":["extension-list","lookup","registration"],"backgroundTag":null,"analyzedSha":"2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc","analyzedAt":"2026-08-14T07:07:15.274Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}