{"record":{"id":"0897c29b9fd6d51e","repo":"jenkinsci/jenkins","slug":"the-class-type-getname-was-not-found-potenti","errorCode":null,"errorMessage":"The class ${type.getName()} was not found, potentially not yet loaded","messagePattern":"The class (.+?) was not found, potentially not yet loaded","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/hudson/ExtensionList.java","lineNumber":154,"sourceCode":"    public @CheckForNull <U extends T> U get(@NonNull Class<U> type) {\n        for (T ext : this)\n            if (ext.getClass() == type)\n                return type.cast(ext);\n        return null;\n    }\n\n    /**\n     * Looks for the extension instance of the given type (subclasses excluded),\n     * or throws an IllegalStateException.\n     *\n     * Meant to simplify call inside @Extension annotated class to retrieve their own instance.\n     */\n    public @NonNull <U extends T> U getInstance(@NonNull Class<U> type) throws IllegalStateException {\n        for (T ext : this)\n            if (ext.getClass() == type)\n                return type.cast(ext);\n\n        throw new IllegalStateException(\"The class \" + type.getName() + \" was not found, potentially not yet loaded\");\n    }\n\n    @Override\n    public @NonNull Iterator<T> iterator() {\n        // we need to intercept mutation, so for now don't allow Iterator.remove\n        return new AdaptedIterator<>(Iterators.readOnly(ensureLoaded().iterator())) {\n            @Override\n            protected T adapt(ExtensionComponent<T> item) {\n                return item.getInstance();\n            }\n        };\n    }\n\n    /**\n     * Gets the same thing as the 'this' list represents, except as {@link ExtensionComponent}s.\n     */\n    public List<ExtensionComponent<T>> getComponents() {\n        return Collections.unmodifiableList(ensureLoaded());","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/jenkinsci/jenkins/blob/2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc/core/src/main/java/hudson/ExtensionList.java#L136-L172","documentation":"Thrown by ExtensionList.getInstance(Class) when iterating the loaded extension components finds none whose exact runtime class equals the requested type. Unlike lookup, this matches by getClass()==type (subclasses excluded), so a registered subclass or an interface type will not match. It is intended for an @Extension class to fetch its own singleton.","triggerScenarios":"Calling getInstance on a type with no exact-class instance; calling it before the extension list has been loaded; passing an interface or superclass instead of the concrete @Extension class; the instance is registered under a different ExtensionList (wrong Jenkins).","commonSituations":"Calling getInstance too early during startup; the extension failed to load (check logs); refactor renamed/moved the class so the registered class differs; multiple Jenkins instances in tests.","solutions":["Use ExtensionList.lookup(Type.class).get(Type.class) for nullable lookup, or lookupFirst for highest-ordinal.","Ensure the extension is actually registered with @Extension and loaded (check Jenkins manage/extensions).","Pass the concrete @Extension class, not a superclass or interface.","If in a test, register the instance manually or use JenkinsRule before calling getInstance."],"exampleFix":"// before\nMyExt me = ExtensionList.lookup(ExtensionPoint.class).getInstance(MyExt.class);\n// may throw if list is for the supertype; use the exact list\n// after\nMyExt me = ExtensionList.lookup(MyExt.class).getInstance(MyExt.class);","handlingStrategy":"type-guard","validationCode":"ExtensionList<T> list = ExtensionList.lookup(MyExt.class);\nif (!list.isEmpty() && list.stream().anyMatch(e -> e.getClass() == MyExt.class)) {\n    MyExt me = list.getInstance(MyExt.class);\n}","typeGuard":"static boolean hasExactInstance(Class<?> type) {\n    return ExtensionList.lookup(type).stream().anyMatch(e -> e.getClass() == type);\n}","tryCatchPattern":"try {\n    MyExt me = ExtensionList.lookup(MyExt.class).getInstance(MyExt.class);\n} catch (IllegalStateException e) {\n    // 'was not found, potentially not yet loaded' — defer or fall back\n}","preventionTips":["Call getInstance only for the concrete @Extension class, not an interface or superclass.","Prefer lookupFirst when you want graceful fallback to highest-ordinal.","Avoid calling during early bootstrap; wait for Jenkins to be fully loaded."],"tags":["extension-list","lookup","lifecycle"],"backgroundTag":null,"analyzedSha":"2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc","analyzedAt":"2026-08-14T07:07:15.274Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}