apache/cassandra · error · ConfigurationException
Cannot access method validateOptions in
Error message
Cannot access method validateOptions in
What it means
CompactionParams.validate() catches IllegalAccessException from the reflective invocation of the strategy class's static validateOptions(Map) and rethrows it as a ConfigurationException saying the method cannot be accessed. This happens when the method exists but is not accessible via reflection (non-public or in a restricted package/module).
Source
Thrown at src/java/org/apache/cassandra/schema/CompactionParams.java:227
}
catch (InvocationTargetException e)
{
if (e.getTargetException() instanceof ConfigurationException)
throw (ConfigurationException) e.getTargetException();
Throwable cause = e.getCause() == null
? e
: e.getCause();
throw new ConfigurationException(format("%s.validateOptions() threw an error: %s %s",
klass.getName(),
cause.getClass().getName(),
cause.getMessage()),
e);
}
catch (IllegalAccessException e)
{
throw new ConfigurationException("Cannot access method validateOptions in " + klass.getName(), e);
}
String minThreshold = options.get(Option.MIN_THRESHOLD.toString());
if (minThreshold != null && !StringUtils.isNumeric(minThreshold))
{
throw new ConfigurationException(format("Invalid value %s for '%s' compaction sub-option - must be an integer",
minThreshold,
Option.MIN_THRESHOLD));
}
String maxThreshold = options.get(Option.MAX_THRESHOLD.toString());
if (maxThreshold != null && !StringUtils.isNumeric(maxThreshold))
{
throw new ConfigurationException(format("Invalid value %s for '%s' compaction sub-option - must be an integer",
maxThreshold,
Option.MAX_THRESHOLD));
}
View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Declare the method exactly as public static Map<String, String> validateOptions(Map<String, String> options) in your strategy class.
- Rebuild and redeploy the custom strategy JAR with the corrected signature/visibility.
- If module access restrictions apply, open the package (e.g. --add-opens) or avoid restricted classloading for strategies.
- Prefer subclassing a built-in strategy so the inherited public validateOptions is used.
Example fix
// before
class MyStrategy extends SizeTieredCompactionStrategy {
static Map<String, String> validateOptions(Map<String, String> options) { ... }
}
// after
class MyStrategy extends SizeTieredCompactionStrategy {
public static Map<String, String> validateOptions(Map<String, String> options) { ... }
} Defensive patterns
Strategy: type-guard
Validate before calling
Method m = strategyClass.getMethod("validateOptions", Map.class);
if (!java.lang.reflect.Modifier.isPublic(m.getModifiers()))
throw new IllegalArgumentException("validateOptions must be public static"); Type guard
boolean validStrategyClass(Class<?> c) {
try { return java.lang.reflect.Modifier.isPublic(c.getMethod("validateOptions", Map.class).getModifiers()); }
catch (NoSuchMethodException e) { return false; }
} Try / catch
try { applyCompaction(opts); } catch (ConfigurationException e) {
if (e.getMessage().startsWith("Cannot access method validateOptions"))
logger.error("Custom strategy {} has non-public validateOptions", e.getMessage());
} Prevention
- Declare custom strategies' validateOptions as public static.
- Test-load custom strategy classes before deploying to production.
- Prefer subclassing built-in strategies to inherit correct visibility.
When it happens
Trigger: Using a custom compaction strategy whose validateOptions(Map) is not declared public static, or a strategy loaded from a restricted classloader/module that blocks reflective access.
Common situations: Third-party/custom compaction strategies missing the public modifier; strategies compiled against different visibility; Java module restrictions when loading custom classes.
Related errors
- Properties specified %s are not understood by %s
- %s.validateOptions() threw an error: %s %s
- concurrent_compactors should be strictly greater than 0, but
- Could not set new local compaction strategy: <cause message>
- The min_compaction_threshold cannot be larger than the max_c
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/85648375efcfb0f9.
Report an issue: GitHub.