{"record":{"id":"76e4a0961dcaa267","repo":"apache/cassandra","slug":"create-method-not-found","errorCode":null,"errorMessage":"create method not found","messagePattern":"create method not found","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/io/compress/DefaultCompressionProvider.java","lineNumber":76,"sourceCode":"     * @throws ConfigurationException if the compressor class does not have a valid create method,\n     * if there are unknown compression options, or if the compressor creation fails\n     */\n    @Override\n    public ICompressor createCompressor(Class<?> compressorClass, Map<String, String> compressionOptions) throws IllegalStateException\n    {\n        try\n        {\n            Method method = compressorClass.getMethod(\"create\", Map.class);\n            ICompressor compressor = (ICompressor)method.invoke(null, compressionOptions);\n            // Check for unknown options\n            for (String provided : compressionOptions.keySet())\n                if (!compressor.supportedOptions().contains(provided))\n                    throw new ConfigurationException(\"Unknown compression options \" + provided);\n            return compressor;\n        }\n        catch (NoSuchMethodException e)\n        {\n            throw new ConfigurationException(\"create method not found\", e);\n        }\n        catch (SecurityException e)\n        {\n            throw new ConfigurationException(\"Access forbidden\", e);\n        }\n        catch (IllegalAccessException e)\n        {\n            throw new ConfigurationException(\"Cannot access method create in \" + compressorClass.getName(), e);\n        }\n        catch (InvocationTargetException e)\n        {\n            if (e.getTargetException() instanceof ConfigurationException)\n                throw (ConfigurationException) e.getTargetException();\n\n            Throwable cause = e.getCause() == null\n                            ? e\n                            : e.getCause();\n","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/compress/DefaultCompressionProvider.java#L58-L94","documentation":"DefaultCompressionProvider creates compressors reflectively via a public static create(Map) method on the compressor class. If getMethod(\"create\", Map.class) finds no such method, the provider cannot construct the compressor and throws this ConfigurationException with the NoSuchMethodException attached.","triggerScenarios":"createCompressor() called with a compressorClass that has no public static ICompressor create(Map<String,String>) method — e.g. a custom or third-party class passed to getCompressor(), or a built-in class whose signature differs across versions.","commonSituations":"Pointing sstable_compression at a custom ICompressor implementation that only has instance factory methods or a constructor; class name typos resolving to a helper class instead of the compressor; running an older Cassandra where the create(Map) signature differs.","solutions":["Add or expose a public static create(Map<String,String>) method on the compressor class that builds and returns an ICompressor.","Verify the class name resolves to the intended ICompressor implementation, not a helper or similarly named class.","Use a built-in compressor class (LZ4Compressor, SnappyCompressor, DeflateCompressor) which all provide create(Map).","If using a custom provider, implement createCompressor() to construct the compressor directly instead of relying on reflection."],"exampleFix":"// before\npublic static MyCompressor create(Map<String,String> options, int extra) { ... }\n// after\npublic static ICompressor create(Map<String,String> options) { ... }","handlingStrategy":"validation","validationCode":"try {\n    Method m = compressorClass.getMethod(\"create\", Map.class);\n    if (!ICompressor.class.isAssignableFrom(m.getReturnType())) throw new IllegalArgumentException(\"create does not return ICompressor\");\n} catch (NoSuchMethodException e) {\n    throw new IllegalArgumentException(compressorClass + \" lacks public static create(Map)\");\n}","typeGuard":"boolean hasCreateMethod(Class<?> c) {\n    try { c.getMethod(\"create\", Map.class); return true; } catch (NoSuchMethodException e) { return false; }\n}","tryCatchPattern":"try {\n    registry.getCompressor(customCompressorClass, opts);\n} catch (ConfigurationException e) {\n    if (e.getMessage().equals(\"create method not found\")) log.error(\"Add public static create(Map<String,String>) to {}\", customCompressorClass);\n    throw e;\n}","preventionTips":["Ensure every custom compressor exposes public static ICompressor create(Map<String,String>)","Smoke-test Class.forName + getMethod(\"create\", Map.class) on custom compressor classes before deployment","Prefer built-in compressor classes when no custom behavior is needed","Pin the Cassandra version and verify factory signatures match it"],"tags":["compression","reflection","classpath"],"backgroundTag":"class-not-found","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"}