apache/cassandra · error · ConfigurationException

Error instantiating class ' '.

Error message

Error instantiating %s class '%s'.

What it means

FBUtilities.classForName/<T>construct instantiates a class by its configured class name via reflection. If instantiation throws any exception whose cause is not a ConfigurationException, it is rethrown as a ConfigurationException with this message. It means a class named in configuration exists and loaded but its constructor failed (or the class could not be instantiated).

Solutions

  1. Inspect the wrapped cause exception in the stack trace to find why the class constructor failed
  2. Fix the class's no-arg constructor (throw ConfigurationException directly if the failure is a config problem)
  3. Verify the class and all its dependencies are on the Cassandra classpath (lib/)
  4. Correct the fully-qualified class name in cassandra.yaml if the wrong class is configured

Example fix

// before: public class MyAuthenticator implements IAuthenticator { public MyAuthenticator() { init(); } }
// after:  public class MyAuthenticator implements IAuthenticator { public MyAuthenticator() { try { init(); } catch (Exception e) { throw new ConfigurationException("init failed: " + e.getMessage()); } } }
Defensive patterns

Strategy: try-catch

Validate before calling

try { Class.forName(className).getDeclaredConstructor().newInstance(); } catch (Throwable t) { /* class/ctor problem before config load */ }

Try / catch

try { T impl = FBUtilities.construct(className, "authenticator"); } catch (ConfigurationException e) { logger.error("Bad class config: {}", e.getCause(), e); throw e; }

Prevention

When it happens

Trigger: Calling FBUtilities.classForName(...).newInstance() or construct() with a class whose no-arg constructor throws (e.g. IAuthenticator, IAuthorizer, SeedProvider, IEndpointSnitch configured in cassandra.yaml whose constructor throws RuntimeException/other checked exceptions).

Common situations: Custom authenticator/authorizer/seed provider classes that throw in their constructors, misconfigured dependencies missing at runtime (NoClassDefFoundError wrapped as cause), or wrong constructor signatures after upgrading a plugin.

Related errors


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

Appendix: source

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

    {
        try
        {
            return cls.newInstance();
        }
        catch (IllegalAccessException e)
        {
            throw new ConfigurationException(String.format("Default constructor for %s class '%s' is inaccessible.", readable, classname));
        }
        catch (InstantiationException e)
        {
            throw new ConfigurationException(String.format("Cannot use abstract class '%s' as %s.", classname, readable));
        }
        catch (Exception e)
        {
            // Catch-all because Class.newInstance() "propagates any exception thrown by the nullary constructor, including a checked exception".
            if (e.getCause() instanceof ConfigurationException)
                throw (ConfigurationException)e.getCause();
            throw new ConfigurationException(String.format("Error instantiating %s class '%s'.", readable, classname), e);
        }
    }

    public static <T> NavigableSet<T> singleton(T column, Comparator<? super T> comparator)
    {
        NavigableSet<T> s = new TreeSet<T>(comparator);
        s.add(column);
        return s;
    }

    public static <T> NavigableSet<T> emptySortedSet(Comparator<? super T> comparator)
    {
        return new TreeSet<T>(comparator);
    }

    /**
     * Make straing out of the given {@code Map}.
     *

View on GitHub (pinned to 88fd0f6a0e)