{"record":{"id":"025ebebb0130bea7","repo":"apache/cassandra","slug":"unable-to-initialize-analyzer-class-option-specifi","errorCode":null,"errorMessage":"Unable to initialize analyzer class option specified [%s]","messagePattern":"Unable to initialize analyzer class option specified \\[(.+?)\\]","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/index/sasi/conf/IndexMode.java","lineNumber":115,"sourceCode":"\n    public static void validateAnalyzer(Map<String, String> indexOptions, ColumnMetadata cd) throws ConfigurationException\n    {\n        // validate that a valid analyzer class was provided if specified\n        if (indexOptions.containsKey(INDEX_ANALYZER_CLASS_OPTION))\n        {\n            Class<? extends AbstractAnalyzer> analyzerClass = FBUtilities.classForNameWithoutInitialization(indexOptions.get(INDEX_ANALYZER_CLASS_OPTION),\n                                                                                                            \"analyzer\",\n                                                                                                            AbstractAnalyzer.class);\n\n            AbstractAnalyzer analyzer;\n            try\n            {\n                analyzer = analyzerClass.newInstance();\n                analyzer.validate(indexOptions, cd);\n            }\n            catch (InstantiationException | IllegalAccessException e)\n            {\n                throw new ConfigurationException(String.format(\"Unable to initialize analyzer class option specified [%s]\",\n                                                               analyzerClass.getSimpleName()));\n            }\n        }\n    }\n\n    public static IndexMode getMode(ColumnMetadata column, Optional<IndexMetadata> config) throws ConfigurationException\n    {\n        return getMode(column, config.isPresent() ? config.get().options : null);\n    }\n\n    public static IndexMode getMode(ColumnMetadata column, Map<String, String> indexOptions) throws ConfigurationException\n    {\n        if (indexOptions == null || indexOptions.isEmpty())\n            return IndexMode.NOT_INDEXED;\n\n        Mode mode;\n\n        try","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/index/sasi/conf/IndexMode.java#L97-L133","documentation":"IndexMode.validateAnalyzer instantiates the user-specified SASI analyzer class reflectively; if newInstance throws InstantiationException or IllegalAccessException (abstract class, no no-arg constructor, non-public class), the failure is rethrown as a ConfigurationException with this message naming the class.","triggerScenarios":"Creating a SASI index with 'analyzer_class' pointing to a class that cannot be instantiated: abstract, interface, no public no-arg constructor, or not public.","commonSituations":"Typo'd or fully custom analyzer classes lacking a public no-arg constructor; deploying a custom analyzer not on the server classpath (leading instead to ClassNotFoundException earlier); inner classes not declared static.","solutions":["Make the analyzer class public, concrete, with a public no-arg constructor","Ship the analyzer class in the Cassandra classpath (custom jar)","Use a built-in analyzer (NonTokenizingAnalyzer, StandardAnalyzer, DelimiterAnalyzer) instead"],"exampleFix":"// before\nclass MyAnalyzer extends AbstractAnalyzer { MyAnalyzer(int x) {...} }\n// after\npublic class MyAnalyzer extends AbstractAnalyzer { public MyAnalyzer() {...} }","handlingStrategy":"validation","validationCode":"Class<?> c = Class.forName(analyzerClassName);\nif (Modifier.isAbstract(c.getModifiers()) || Modifier.isInterface(c.getModifiers())\n    || !Modifier.isPublic(c.getModifiers())\n    || java.util.Arrays.stream(c.getConstructors()).noneMatch(ctor -> ctor.getParameterCount() == 0 && Modifier.isPublic(ctor.getModifiers())))\n  throw new ConfigurationException(\"Analyzer class must be public, concrete, with a public no-arg constructor: \" + analyzerClassName);","typeGuard":null,"tryCatchPattern":"try { session.execute(createIndexCql); } catch (ConfigurationException e) { if (e.getMessage().startsWith(\"Unable to initialize analyzer class\")) { log.error(\"Check analyzer class: public, concrete, no-arg constructor, on server classpath\", e); } throw e; }","preventionTips":["Analyzer classes must be public, non-abstract, with a public no-arg constructor","Deploy custom analyzer jars to every node's classpath","Smoke-test analyzer instantiation with a unit test"],"tags":["sasi","reflection","analyzer","configuration"],"backgroundTag":"module-init-failed","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}