apache/cassandra · error · IllegalArgumentException

Invalid replication strategy:

Error message

Invalid replication strategy: 

What it means

OptionReplication resolves a replication strategy class name (e.g. NetworkTopologyStrategy) via a lookup of known strategies. When the name cannot be resolved to any known strategy class, apply() throws this IllegalArgumentException indicating the strategy name is invalid.

Solutions

  1. Correct the strategy name spelling/casing to an exact match, e.g. 'SimpleStrategy' or 'NetworkTopologyStrategy'.
  2. Check which replication strategies your Cassandra version supports and use one of those.
  3. Pass the strategy with its required options, e.g. replication_factor=3 for SimpleStrategy or datacenter names for NetworkTopologyStrategy.
  4. Use the default strategy by omitting the replication_strategy option entirely.

Example fix

// before
String opts = "replication_strategy=SimpleReplication,replication_factor=3";
// after
String opts = "replication_strategy=SimpleStrategy,replication_factor=3";
Defensive patterns

Strategy: validation

Validate before calling

Set<String> valid = Set.of("SimpleStrategy", "NetworkTopologyStrategy", "LocalStrategy", "EverywhereStrategy");
if (!valid.contains(strategyName)) throw new IllegalArgumentException("unknown strategy: " + strategyName);

Try / catch

try { /* build settings */ } catch (IllegalArgumentException e) { if (e.getMessage().startsWith("Invalid replication strategy")) { System.err.println("Use SimpleStrategy or NetworkTopologyStrategy"); } else throw e; }

Prevention

When it happens

Trigger: Running cassandra-stress with a replication option whose strategy name does not match any known IStrategyFactory/strategy class, e.g. -node "replication_strategy=SimpleReplication" — the initial reflection/lookup attempt throws (caught and ignored) and strategy remains null.

Common situations: Typo like 'SimpleStrategyy' or 'Simple' instead of 'SimpleStrategy'; using a strategy that exists in newer Cassandra versions than the stress tool being run; wrong case (strategy names are matched exactly); copying a DSE-only strategy name into OSS cassandra-stress.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/c96ef8af06c44187. Report an issue: GitHub.

Appendix: source

Thrown at tools/stress/src/org/apache/cassandra/stress/settings/OptionReplication.java:91

        public String apply(String name)
        {
            String strategy = null;
            for (String fullname : new String[] { name, "org.apache.cassandra.locator." + name })
            {
                try
                {
                    FBUtilities.classForNameWithoutInitialization(fullname,
                                                                  "replication strategy",
                                                                  AbstractReplicationStrategy.class);
                    strategy = fullname;
                    break;
                } catch (Exception ignore)
                {
                    // will throw below if strategy is still null
                }
            }
            if (strategy == null)
                throw new IllegalArgumentException("Invalid replication strategy: " + name);
            return strategy;
        }
    }

}

View on GitHub (pinned to 88fd0f6a0e)