apache/cassandra · error · ConfigurationException

Unable to find class

Error message

Unable to find %s class '%s'

What it means

classForName loads and initializes a class by name and verifies nothing; if Class.forName cannot find it (ClassNotFoundException or NoClassDefFoundError), it throws a ConfigurationException identifying the readable description and class name. It is the generic reflective class-loading entry point for pluggable components.

Solutions

  1. Fix the class name in configuration to the correct fully-qualified name
  2. Add the missing jar to lib/ on all nodes and restart
  3. If NoClassDefFoundError, check the chained cause for the real missing class and add that dependency
  4. Ensure jar versions match your Cassandra version

Example fix

// before (cassandra.yaml)
seed_provider:
  - class_name: org.apache.cassandra.locator.SimpleSeedProvide
// after
seed_provider:
  - class_name: org.apache.cassandra.locator.SimpleSeedProvider
Defensive patterns

Strategy: validation

Validate before calling

boolean classExists(String cn) {
    try { Class.forName(cn, false, Thread.currentThread().getContextClassLoader()); return true; }
    catch (Throwable t) { return false; }
}

Try / catch

try {
    Class<?> cls = FBUtilities.classForName(name, readable);
} catch (ConfigurationException e) {
    logger.error("Cannot load " + readable + ": " + name + " — check classpath/config", e);
    throw e;
}

Prevention

When it happens

Trigger: Any configuration-driven class name (seed provider, SSTable format, auth, etc.) passed to FBUtilities.classForName that is not present on the classpath or fails to link.

Common situations: Missing dependency jar in lib/; typo in fully-qualified class name; NoClassDefFoundError caused by a transitive dependency failure or version mismatch; shading/renaming after upgrade.

Related errors


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

Appendix: source

Thrown at src/java/org/apache/cassandra/utils/FBUtilities.java:780

    }

    /**
     * Loads and initializes a class.
     *
     * @return The Class for the given name.
     * @param classname Fully qualified classname.
     * @param readable Descriptive noun for the role the class plays.
     * @throws ConfigurationException If the class cannot be found.
     */
    public static <T> Class<T> classForName(String classname, String readable) throws ConfigurationException
    {
        try
        {
            return (Class<T>)Class.forName(classname);
        }
        catch (ClassNotFoundException | NoClassDefFoundError e)
        {
            throw new ConfigurationException(String.format("Unable to find %s class '%s'", readable, classname), e);
        }
    }

    /**
     * Loads a class without initializing it, then verifies it extends or implements the expected base type.
     *
     * @return The Class for the given name.
     * @param classname Fully qualified classname.
     * @param readable Descriptive noun for the role the class plays.
     * @param expectedType Required superclass or interface.
     * @throws ConfigurationException If the class cannot be found or is not assignable to {@code expectedType}.
     */
    public static <T> Class<? extends T> classForNameWithoutInitialization(String classname,
                                                                           String readable,
                                                                           Class<T> expectedType) throws ConfigurationException
    {
        return classForNameWithoutInitialization(classname, readable, expectedType, FBUtilities.class.getClassLoader());
    }

View on GitHub (pinned to 88fd0f6a0e)