{"record":{"id":"e9129d85604baef4","repo":"apache/cassandra","slug":"default-constructor-for-s-class-s-is-inaccessi","errorCode":null,"errorMessage":"Default constructor for %s class '%s' is inaccessible.","messagePattern":"Default constructor for (.+?) class '(.+?)' is inaccessible\\.","errorType":"exception","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/utils/FBUtilities.java","lineNumber":904,"sourceCode":"     * @param readable Descriptive noun for the role the class plays.\n     * @param expectedType Required superclass or interface.\n     * @throws ConfigurationException If the class cannot be found or is not assignable to {@code expectedType}.\n     */\n    public static <T> T construct(String classname, String readable, Class<T> expectedType) throws ConfigurationException\n    {\n        Class<? extends T> cls = FBUtilities.classForNameWithoutInitialization(classname, readable, expectedType);\n        return construct(cls, classname, readable);\n    }\n\n    private static <T> T construct(Class<? extends T> cls, String classname, String readable) throws ConfigurationException\n    {\n        try\n        {\n            return cls.newInstance();\n        }\n        catch (IllegalAccessException e)\n        {\n            throw new ConfigurationException(String.format(\"Default constructor for %s class '%s' is inaccessible.\", readable, classname));\n        }\n        catch (InstantiationException e)\n        {\n            throw new ConfigurationException(String.format(\"Cannot use abstract class '%s' as %s.\", classname, readable));\n        }\n        catch (Exception e)\n        {\n            // Catch-all because Class.newInstance() \"propagates any exception thrown by the nullary constructor, including a checked exception\".\n            if (e.getCause() instanceof ConfigurationException)\n                throw (ConfigurationException)e.getCause();\n            throw new ConfigurationException(String.format(\"Error instantiating %s class '%s'.\", readable, classname), e);\n        }\n    }\n\n    public static <T> NavigableSet<T> singleton(T column, Comparator<? super T> comparator)\n    {\n        NavigableSet<T> s = new TreeSet<T>(comparator);\n        s.add(column);","sourceCodeStart":886,"sourceCodeEnd":922,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/utils/FBUtilities.java#L886-L922","documentation":"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.","triggerScenarios":"Configured plugin class has a default (no-arg) constructor declared non-public (private/protected/package-private), so cls.newInstance() cannot invoke it.","commonSituations":"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.","solutions":["Make the no-arg constructor public in your custom class","Ensure the class itself is public and top-level (or public static nested)","If the class requires a Map constructor instead, use the appropriate factory method (e.g. newAuditLogger/newSslContextFactory)","Redeploy the fixed jar to all nodes and restart"],"exampleFix":"// before\nprivate MySeedProvider() {}\n// after\npublic MySeedProvider() {}","handlingStrategy":"validation","validationCode":"boolean hasPublicNoArgCtor(String cn) {\n    try { Class.forName(cn).getConstructor(); return true; }\n    catch (Throwable t) { return false; }\n}\n// guard before configuring: if (!hasPublicNoArgCtor(className)) failFast();","typeGuard":null,"tryCatchPattern":"try {\n    Object plugin = FBUtilities.constructorForName(className, readable);\n} catch (ConfigurationException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"is inaccessible\"))\n        logger.error(\"Make the no-arg constructor of \" + className + \" public\");\n    throw e;\n}","preventionTips":["Always declare a public no-arg constructor on configurable plugin classes","Avoid singleton-style private constructors for plugin classes","Keep plugin classes public and top-level (or public static nested)","Add a startup test that instantiates each configured plugin"],"tags":["reflection","constructor","access"],"backgroundTag":"invalid-constructor-argument","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}