apache/cassandra · error · ConfigurationException
Unable to create instance of validator of class
Error message
Unable to create instance of validator of class %s: %s
What it means
Cassandra guardrails support a custom validator class that validates generated/configured values. ValueValidator.getValidator reflectively instantiates the class configured for a guardrail (e.g. password_policy_validator); when that fails — missing class, missing public no-arg constructor, constructor throwing, wrong type — it wraps the failure in a ConfigurationException with this message.
Solutions
- Check that the configured value is the correct fully-qualified class name of a ValueValidator subclass
- Deploy the validator class/JAR to Cassandra's classpath
- Add a public no-arg constructor to the validator class
- Read the nested message in the exception — ConfigurationException causes are unwrapped into the message
- Run ValueValidator.getValidator(name, config) in a unit test before rollout
Example fix
// before
role_name_policy_validator: com.example.RoleNameValidator // ctor takes args
// after
public class RoleNameValidator extends ValueValidator<String> { public RoleNameValidator() {} ... } Defensive patterns
Strategy: validation
Validate before calling
String cls = config.password_policy_validator;
if (cls != null && !cls.isBlank()) {
try {
Class<?> c = Class.forName(cls.trim());
if (!org.apache.cassandra.db.guardrails.ValueValidator.class.isAssignableFrom(c))
throw new IllegalArgumentException(cls + " is not a ValueValidator");
c.getDeclaredConstructor();
} catch (ReflectiveOperationException e) {
throw new IllegalArgumentException("Cannot load validator " + cls + ": " + e, e);
}
} Type guard
boolean isValidValidator(String name) {
try { return ValueValidator.class.isAssignableFrom(Class.forName(name)); }
catch (Throwable t) { return false; }
} Try / catch
try {
validator = ValueValidator.getValidator("password_policy", config);
} catch (ConfigurationException e) {
logger.error("Invalid validator class: {}", e.getMessage());
validator = NoOpValidator.INSTANCE;
} Prevention
- Test-load configured validator classes in CI with the same classpath as production
- Keep custom validators in a dedicated JAR versioned with your Cassandra version
- Prefer built-in validators unless customization is required
- Read the nested ConfigurationException message first — it names the actual init failure
When it happens
Trigger: Setting a guardrail validator option to a class name that cannot be reflectively instantiated at startup or when the guardrail is first used.
Common situations: Misspelled fully-qualified class name in cassandra.yaml; validator JAR not deployed to lib/; validator class has a parameterized constructor; class was compiled against an incompatible Cassandra version; nested ConfigurationException from the validator's static/instance init.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- Unable to create instance of generator of class
- Cannot find configured row cache provider class
- couldn't load cipher factory
- default_keyspace_rf to be set
- default_keyspace_rf to be set
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/5aa24dfba67f9dfa.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/db/guardrails/ValueValidator.java:151
Class<? extends ValueValidator<VALUE>> validatorClass =
(Class<? extends ValueValidator<VALUE>>) rawValidatorClass;
@SuppressWarnings("unchecked")
ValueValidator<VALUE> validator = validatorClass.getConstructor(CustomGuardrailConfig.class)
.newInstance(config);
logger.debug("Using {} validator for guardrail '{}' with parameters {}",
validator.getClass(), name, validator.getParameters());
return validator;
}
catch (Exception ex)
{
String message;
if (ex.getCause() instanceof ConfigurationException)
message = ex.getCause().getMessage();
else
message = ex.getMessage();
throw new ConfigurationException(format("Unable to create instance of validator of class %s: %s",
className, message), ex);
}
}
}
View on GitHub (pinned to 88fd0f6a0e)