apache/cassandra · error · ConfigurationException

Default constructor for

Error message

Default constructor for %s class '%s' is inaccessible.

What it means

construction with a no-arg constructor via Class.newInstance(). If the default constructor exists but is not accessible (IllegalAccessException), a ConfigurationException 'Default constructor ... is inaccessible' is thrown. This is thrown during reflective instantiation of configured plugin classes.

Solutions

  1. Make the no-arg constructor public in your custom class
  2. Ensure the class itself is public and top-level (or public static nested)
  3. If the class requires a Map constructor instead, use the appropriate factory method (e.g. newAuditLogger/newSslContextFactory)
  4. Redeploy the fixed jar to all nodes and restart

Example fix

// before
private MySeedProvider() {}
// after
public MySeedProvider() {}
Defensive patterns

Strategy: validation

Validate before calling

boolean hasPublicNoArgCtor(String cn) {
    try { Class.forName(cn).getConstructor(); return true; }
    catch (Throwable t) { return false; }
}
// guard before configuring: if (!hasPublicNoArgCtor(className)) failFast();

Try / catch

try {
    Object plugin = FBUtilities.constructorForName(className, readable);
} catch (ConfigurationException e) {
    if (e.getMessage() != null && e.getMessage().contains("is inaccessible"))
        logger.error("Make the no-arg constructor of " + className + " public");
    throw e;
}

Prevention

When it happens

Trigger: Configured plugin class has a default (no-arg) constructor declared non-public (private/protected/package-private), so cls.newInstance() cannot invoke it.

Common situations: Custom class written with a private constructor (singleton pattern) but registered as a configurable plugin; nested non-public class; access restrictions from package/module visibility.

Related errors


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

Appendix: source

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

     * @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> T construct(String classname, String readable, Class<T> expectedType) throws ConfigurationException
    {
        Class<? extends T> cls = FBUtilities.classForNameWithoutInitialization(classname, readable, expectedType);
        return construct(cls, classname, readable);
    }

    private static <T> T construct(Class<? extends T> cls, String classname, String readable) throws ConfigurationException
    {
        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);

View on GitHub (pinned to 88fd0f6a0e)