apache/dubbo · error · IllegalArgumentException

ExtensionLoader for [${type}] is not found

Error message

ExtensionLoader for [${type}] is not found

What it means

Thrown by ExtensionAccessor.getFirstActivateExtension(type) when getExtensionLoader(type) returns null — meaning no ExtensionLoader is registered for the given type in the current ScopeModel's ExtensionDirector. This indicates the type is either not a Dubbo SPI interface or the extension director has not been initialized for it.

Source

Thrown at dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionAccessor.java:57

    default <T> T getAdaptiveExtension(Class<T> type) {
        ExtensionLoader<T> extensionLoader = getExtensionLoader(type);
        return extensionLoader != null ? extensionLoader.getAdaptiveExtension() : null;
    }

    default <T> T getDefaultExtension(Class<T> type) {
        ExtensionLoader<T> extensionLoader = getExtensionLoader(type);
        return extensionLoader != null ? extensionLoader.getDefaultExtension() : null;
    }

    default <T> List<T> getActivateExtensions(Class<T> type) {
        ExtensionLoader<T> extensionLoader = getExtensionLoader(type);
        return extensionLoader != null ? extensionLoader.getActivateExtensions() : Collections.emptyList();
    }

    default <T> T getFirstActivateExtension(Class<T> type) {
        ExtensionLoader<T> extensionLoader = getExtensionLoader(type);
        if (extensionLoader == null) {
            throw new IllegalArgumentException("ExtensionLoader for [" + type + "] is not found");
        }
        List<T> extensions = extensionLoader.getActivateExtensions();
        if (extensions.isEmpty()) {
            throw new IllegalArgumentException("No activate extensions for [" + type + "] found");
        }
        return extensions.get(0);
    }

    default Set<String> getSupportedExtensions(Class<?> type) {
        ExtensionLoader<?> extensionLoader = getExtensionLoader(type);
        return extensionLoader != null ? extensionLoader.getSupportedExtensions() : Collections.emptySet();
    }
}

View on GitHub (pinned to 3a3043227f)

Solutions

  1. Verify the type is a Dubbo SPI interface (has corresponding META-INF/dubbo/ or META-INF/services/ extension config files).
  2. Ensure you are calling on the correct ScopeModel's ExtensionAccessor (e.g. applicationModel.getExtensionDirector()).
  3. If the type genuinely has no loader, use getSupportedExtensions(type) which returns an empty set instead of throwing.

Example fix

// before
T ext = scopeModel.getFirstActivateExtension(NonSpiClass.class);

// after
T ext = scopeModel.getFirstActivateExtension(RealSpiInterface.class);
Defensive patterns

Strategy: validation

Validate before calling

ExtensionLoader<?> loader = scopeModel.getExtensionLoader(type);
if (loader == null) {
    // type is not a registered SPI — use fallback or getSupportedExtensions
}

Type guard

static boolean isRegisteredSpi(ExtensionAccessor accessor, Class<?> type) {
    return accessor.getExtensionLoader(type) != null;
}

Try / catch

try {
    return accessor.getFirstActivateExtension(type);
} catch (IllegalArgumentException e) {
    if (e.getMessage().contains("is not found")) {
        return null; // or use getExtension(type, name)
    } else throw e;
}

Prevention

When it happens

Trigger: Calling getFirstActivateExtension(SomeClass.class) where SomeClass is not a recognized SPI interface, or the ExtensionDirector for the current scope has no loader for that type. getExtensionLoader returns null (not throws) for unrecognized types, and getFirstActivateExtension then throws this IllegalArgumentException.

Common situations: Passing a non-SPI class (a plain POJO, a concrete implementation class, or a class without META-INF/dubbo SPI config) to getFirstActivateExtension. Also happens when calling on an ExtensionAccessor whose ExtensionDirector is from a different/unrelated ScopeModel.

Related errors


AI-assisted analysis of apache/dubbo@3a3043227f (2026-08-14). Data as JSON: /api/errors/189ac8073fea64fb. Report an issue: GitHub.