apache/pulsar · error · IllegalArgumentException

Field '${name}' with value '${o}' does not implement any of

Error message

Field '${name}' with value '${o}' does not implement any of these classes ${Arrays.toString(classesImplements)}

What it means

Thrown when the configured class loads successfully but implements none of the required interfaces/classes. The validator loops over every required type counting assignable matches; if count stays 0 after all checks, the field fails validation with the full list of accepted supertypes.

Source

Thrown at pulsar-config-validation/src/main/java/org/apache/pulsar/config/validation/ValidatorImpls.java:201

                return;
            }
            SimpleTypeValidator.validateField(name, String.class, o);
            String className = (String) o;
            int count = 0;
            for (Class<?> classImplements : classesImplements) {
                Class<?> objectClass = null;
                try {
                    objectClass = loadClass(className);
                } catch (ClassNotFoundException e) {
                    throw new IllegalArgumentException("Cannot find/load class " + className);
                }

                if (classImplements.isAssignableFrom(objectClass)) {
                    count++;
                }
            }
            if (count == 0) {
                throw new IllegalArgumentException(
                        String.format("Field '%s' with value '%s' does not implement any of these classes %s",
                                name, o, Arrays.toString(classesImplements)));
            }
        }
    }

    /**
     * validates each key and each value against the respective arrays of validators.
     */
    public static class MapEntryCustomValidator extends Validator {

        private Class<?>[] keyValidators;
        private Class<?>[] valueValidators;

        public MapEntryCustomValidator(Map<String, Object> params) {
            this.keyValidators = (Class<?>[]) params.get(
                    ConfigValidationAnnotations.ValidatorParams.KEY_VALIDATOR_CLASSES);
            this.valueValidators = (Class<?>[]) params.get(

View on GitHub (pinned to 820761864e)

Solutions

  1. Configure a class that implements at least one of the interfaces listed in the message.
  2. Check the class's 'implements'/'extends' clauses against the required list and add the appropriate interface.
  3. Verify the deployed jar version provides the implementation of the expected interface.
  4. If you intended a different validator (single-interface), confirm the field is mapped to the right config key.

Example fix

// before
MyConfigurable cfg = new com.example.NotConfigurable(); // implements nothing required
// after
public class MyConfigurableImpl implements Configurable { /* ... */ }
MyConfigurable cfg = new com.example.MyConfigurableImpl();
Defensive patterns

Strategy: validation

Validate before calling

boolean implementsAny(String className, Class<?>... required) {
    try {
        Class<?> c = Class.forName(className, false,
            Thread.currentThread().getContextClassLoader());
        for (Class<?> r : required) {
            if (r.isAssignableFrom(c)) return true;
        }
    } catch (ClassNotFoundException ignored) { }
    return false;
}

Try / catch

try {
    validator.validateField("sourceClass", className);
} catch (IllegalArgumentException e) {
    log.error("{} implements none of the required interfaces — see message for the accepted list", className, e);
    throw new ConfigurationException(e.getMessage(), e);
}

Prevention

When it happens

Trigger: A config field validated with a validator built from multiple classes (classesImplements) is set to a class name whose Class object satisfies none of them — count == 0 after the loop.

Common situations: User configures a valid class of the wrong family (e.g. a sink impl where a source impl is required); a refactored class dropped its interface; wrong version of a library where the interface set differs.

Related errors


AI-assisted analysis of apache/pulsar@820761864e (2026-09-06). Data as JSON: /api/errors/d32481bc08225214. Report an issue: GitHub.