{"record":{"id":"308dbb2c998dfa1f","repo":"languagetool-org/languagetool","slug":"could-not-find-filter-class-classname-make-308dbb","errorCode":null,"errorMessage":"Could not find filter class: '${className}' - make sure to use a fully qualified class name like 'org.languagetool.rules.MyFilter'","messagePattern":"Could not find filter class: '(.+?)' - make sure to use a fully qualified class name like 'org\\.languagetool\\.rules\\.MyFilter'","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-core/src/main/java/org/languagetool/rules/patterns/RuleFilterCreator.java","lineNumber":68,"sourceCode":"            + className + \"' must have exactly one constructor, but it has \" + constructors.length);\n        }\n        Constructor<?> constructor = constructors[0];\n        try {\n          if (constructor.getParameterTypes().length != 0) {\n            throw new RuntimeException(\"Constructor of filter class '\" + className + \"' must not have arguments: \" + constructor);\n          }\n          Object filter = constructor.newInstance();\n          if (filter instanceof RuleFilter) {\n            return (RuleFilter) filter;\n          } else {\n            throw new RuntimeException(\"Filter class '\" + className + \"' must implement interface \" + RuleFilter.class.getSimpleName());\n          }\n        } catch (Exception e) {\n          throw new RuntimeException(\"Could not create filter class using constructor \" + constructor, e);\n        }\n      });\n    } catch (ClassNotFoundException e) {\n      throw new RuntimeException(\"Could not find filter class: '\"\n              + className + \"' - make sure to use a fully qualified class name like 'org.languagetool.rules.MyFilter'\");\n    }\n  }\n\n  public static @NotNull RuleFilterCreator getInstance() {\n    return INSTANCE;\n  }\n}\n","sourceCodeStart":50,"sourceCodeEnd":77,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-core/src/main/java/org/languagetool/rules/patterns/RuleFilterCreator.java#L50-L77","documentation":"RuleFilterCreator.getFilter catches ClassNotFoundException from Class.forName(className) and throws a RuntimeException telling you the filter class could not be found and that a fully qualified class name must be used. It means the JVM class loader could not locate the class named in the filter attribute at runtime.","triggerScenarios":"Calling getFilter(className) with a class name not on the classpath: a simple name like 'MyFilter' instead of 'org.languagetool.rules.MyFilter', a typo in the package, or a JAR/module not included in the runtime classpath (e.g. missing from languagetool-commandline or the LT server's libs).","commonSituations":"Writing the short class name in rule XML instead of the FQCN; the filter lives in a custom extension JAR that was never added to LanguageTool's classpath; package renamed after a refactor while rule XML still references the old one; class only exists in test sources, not in the shipped artifact.","solutions":["Use the fully qualified class name (package + class) in the filter attribute, e.g. org.languagetool.rules.en.MyFilter.","Verify the spelling of package and class name against the actual source file.","Make sure the JAR containing the filter class is on the runtime classpath of the LanguageTool process (server, command line, or embedded).","If the class exists only in src/test, move it to a main source set or a shipped module.","Check for recent renames/moves of the class and update all rule XML references."],"exampleFix":"<!-- before -->\n<filter class=\"MyFilter\"/>\n<!-- after -->\n<filter class=\"org.languagetool.rules.en.MyFilter\"/>","handlingStrategy":"validation","validationCode":"try {\n  Class.forName(fqcn);\n} catch (ClassNotFoundException e) {\n  throw new IllegalArgumentException(\"Filter class not on classpath: \" + fqcn);\n}","typeGuard":null,"tryCatchPattern":"try {\n  RuleFilter f = RuleFilterCreator.getInstance().getFilter(fqcn);\n} catch (RuntimeException e) {\n  if (e.getMessage().contains(\"Could not find filter class\")) {\n    log.error(\"Use FQCN and ensure the JAR is on the classpath: {}\", fqcn);\n  }\n  throw e;\n}","preventionTips":["Always use the fully qualified class name in filter attributes.","Add the module/JAR with custom filters to the runtime classpath of server or command-line runs.","Update rule XML files whenever packages are renamed.","Smoke-test rule loading at startup instead of only at match time."],"tags":["java","classpath","class-not-found","language-tool"],"backgroundTag":"class-not-found","analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}