apache/dubbo · critical · IllegalStateException

No adaptive method exist on extension ${type.getName()}, ref

Error message

No adaptive method exist on extension ${type.getName()}, refuse to create the adaptive class!

What it means

Thrown by AdaptiveClassCodeGenerator.generate() at class-generation time (not runtime) when the SPI interface has zero methods annotated with @Adaptive. The generator refuses to produce an adaptive class because there would be nothing to delegate adaptively. This is a configuration/design error in the SPI interface itself.

Source

Thrown at dubbo-common/src/main/java/org/apache/dubbo/common/extension/AdaptiveClassCodeGenerator.java:109

    private boolean hasAdaptiveMethod() {
        return Arrays.stream(type.getMethods()).anyMatch(m -> m.isAnnotationPresent(Adaptive.class));
    }

    /**
     * generate and return class code
     */
    public String generate() {
        return this.generate(false);
    }

    /**
     * generate and return class code
     * @param sort - whether sort methods
     */
    public String generate(boolean sort) {
        // no need to generate adaptive class since there's no adaptive method found.
        if (!hasAdaptiveMethod()) {
            throw new IllegalStateException("No adaptive method exist on extension " + type.getName()
                    + ", refuse to create the adaptive class!");
        }

        StringBuilder code = new StringBuilder();
        code.append(generatePackageInfo());
        code.append(generateImports());
        code.append(generateClassDeclaration());

        Method[] methods = type.getMethods();
        if (sort) {
            Arrays.sort(methods, Comparator.comparing(Method::toString));
        }
        for (Method method : methods) {
            code.append(generateMethod(method));
        }
        code.append('}');

        if (logger.isDebugEnabled()) {

View on GitHub (pinned to 3a3043227f)

Solutions

  1. Add @Adaptive to at least one method on the SPI interface that should be routed adaptively based on URL parameters.
  2. If no adaptive behavior is needed, do not call getAdaptiveExtension() — use getExtension(name) to obtain a specific implementation instead.
  3. Verify the @Adaptive import is org.apache.dubbo.common.extension.Adaptive and not a different annotation with the same simple name.

Example fix

// before
public interface MySpi {
    String doWork(URL url);
}

// after
public interface MySpi {
    @Adaptive
    String doWork(URL url);
}
Defensive patterns

Strategy: validation

Validate before calling

boolean hasAdaptive = Arrays.stream(spiInterface.getMethods())
    .anyMatch(m -> m.isAnnotationPresent(Adaptive.class));
if (!hasAdaptive) {
    // do not call getAdaptiveExtension — design fix needed
}

Type guard

static boolean hasAdaptiveMethod(Class<?> spiType) {
    return spiType != null && Arrays.stream(spiType.getMethods())
        .anyMatch(m -> m.isAnnotationPresent(Adaptive.class));
}

Try / catch

try {
    return loader.getAdaptiveExtension();
} catch (IllegalStateException e) {
    if (e.getMessage().contains("No adaptive method")) {
        return loader.getDefaultExtension(); // or getExtension(name)
    } else throw e;
}

Prevention

When it happens

Trigger: ExtensionLoader.getAdaptiveExtension() is called for an interface that has no @Adaptive methods. Internally, generate() calls hasAdaptiveMethod() which checks all public methods for the annotation; if none is found, it throws. This happens during Dubbo startup or first access of the adaptive extension.

Common situations: A custom SPI interface was declared but none of its methods carry @Adaptive. Or an existing SPI's @Adaptive annotation was accidentally removed during a refactor. Dubbo's own core SPIs always have at least one adaptive method; this error almost always points to a user-defined SPI.

Related errors


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