infinilabs/analysis-ik · critical · RuntimeException
ik-analyzer: " + name + " not found!!!
Error message
ik-analyzer: " + name + " not found!!!
What it means
While Dictionary.initial(Configuration) loads the IK dictionaries, loadDictFile wraps a FileNotFoundException in a RuntimeException when the file is marked critical (the built-in dictionaries such as main.dic and the stopword dict, unlike optional ext dictionaries). The message embeds the dictionary name that could not be opened. It aborts the whole initialization, so no working dictionary is left behind — segmentation is unavailable until the file is restored.
Source
Thrown at core/src/main/java/org/wltea/analyzer/dic/Dictionary.java:209
}
private void loadDictFile(DictSegment dict, Path file, boolean critical, String name) {
try (InputStream is = new FileInputStream(file.toFile())) {
BufferedReader br = new BufferedReader(
new InputStreamReader(is, "UTF-8"), 512);
String word = br.readLine();
if (word != null) {
if (word.startsWith("\uFEFF"))
word = word.substring(1);
for (; word != null; word = br.readLine()) {
word = word.trim();
if (word.isEmpty()) continue;
dict.fillSegment(word.toCharArray());
}
}
} catch (FileNotFoundException e) {
logger.error("ik-analyzer: " + name + " not found", e);
if (critical) throw new RuntimeException("ik-analyzer: " + name + " not found!!!", e);
} catch (IOException e) {
logger.error("ik-analyzer: " + name + " loading failed", e);
}
}
private List<String> getExtDictionarys() {
List<String> extDictFiles = new ArrayList<String>(2);
String extDictCfg = getProperty(EXT_DICT);
if (extDictCfg != null) {
String[] filePaths = extDictCfg.split(";");
for (String filePath : filePaths) {
if (filePath != null && !"".equals(filePath.trim())) {
Path file = configuration.getPath(getDictRoot(), filePath.trim());
walkFileTree(extDictFiles, file);
}
}
View on GitHub (pinned to 6d2d70fd1a)
Solutions
- Verify the dictionary file named in the message exists under the conf directory the logger printed ('try load config from ...') — restore it from the distribution zip if missing
- Check IKAnalyzer.cfg.xml location and that its entries (main dict, stopword dict, ext paths) resolve relative to that directory; fix absolute/relative paths or the deployment working directory
- Confirm read permission and exact case of the filename on case-sensitive filesystems (Linux) when packaging custom images
- As a last resort in embedded usage, ship a minimal main.dic — an empty but present file passes the loader since empty lines are skipped
Example fix
# before: plugin deployed without its config directory plugins/ik-analyzer/*.jar # no config/ -> RuntimeException on startup # after: restore the shipped config directory next to the jars plugins/ik-analyzer/config/IKAnalyzer.cfg.xml plugins/ik-analyzer/config/main.dic plugins/ik-analyzer/config/stopword.dic
Defensive patterns
Strategy: validation
Validate before calling
Path confDir = configDir; // the directory you pass to your Configuration
String[] criticalDicts = {"main.dic", "stopword.dic"};
for (String d : criticalDicts) {
if (!Files.isRegularFile(confDir.resolve(d)) || !Files.isReadable(confDir.resolve(d))) {
throw new IllegalStateException("missing critical dictionary: " + confDir.resolve(d));
}
}
Dictionary.initial(cfg); Try / catch
try {
Dictionary.initial(cfg);
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().contains("not found!!!")) {
throw new IllegalStateException("IK dictionary files missing from config dir — check deployment layout", e);
}
throw e;
} Prevention
- Include the config/ directory (IKAnalyzer.cfg.xml plus all .dic files) in every artifact that ships the IK jar
- Smoke-test deployments with a one-token analysis request before going live so init failures surface at rollout, not first query
- Keep dictionary filenames lowercase and match case exactly on Linux/container filesystems
- Pin the conf directory explicitly (absolute path or config-in-plugin-dir) instead of relying on the process working directory
When it happens
Trigger: Dictionary.initial(cfg) (or the first IKAnalyzer/IKTokenizer operation that triggers dictionary loading) with a critical .dic file absent from the resolved conf directory: conf_dir or the plugin config dir does not contain main.dic/stopword.dic, the path recorded in IKAnalyzer.cfg.xml resolves against the wrong working directory, or file permissions deny read so FileInputStream reports not-found/unopenable. Non-critical ext files only log; critical built-in files throw.
Common situations: Running IK Analyzer (often the Elasticsearch/Opensearch plugin form) outside its packaged layout: unzipping the plugin without the config/ directory, Docker images that copy the jar but not the dic files, IDE tests where the working directory is not the project root so relative conf paths break, case-sensitive filesystems mangling 'Main.dic' vs 'main.dic', and upgrades that restructured the config directory layout.
Related errors
AI-assisted analysis of infinilabs/analysis-ik@6d2d70fd1a (2026-08-14).
Data as JSON: /api/errors/782ec023f9d7a120.
Report an issue: GitHub.