antlr/antlr4 · critical
ANTLR installation corrupted; cannot find ANTLR messages for
Error message
ANTLR installation corrupted; cannot find ANTLR messages format file + fileName
What it means
Emitted by the ANTLR tool's ErrorManager when the classloader cannot locate the StringTemplate messages group file (org/antlr/v4/tool/templates/messages/format/antlr.stg) that defines all tool message formats. The tool then calls panic(), aborting, because without the format file it cannot render any diagnostics. This almost always means the antlr jar/classpath is broken or incomplete.
Source
Thrown at tool/src/org/antlr/v4/tool/ErrorManager.java:232
/** The format gets reset either from the Tool if the user supplied a command line option to that effect
* Otherwise we just use the default "antlr".
*/
public void setFormat(String formatName) {
STGroupFile loadedFormat;
synchronized (loadedFormats) {
loadedFormat = loadedFormats.get(formatName);
if (loadedFormat == null) {
String fileName = FORMATS_DIR + formatName + STGroup.GROUP_FILE_EXTENSION;
ClassLoader cl = Thread.currentThread().getContextClassLoader();
URL url = cl.getResource(fileName);
if (url == null) {
cl = ErrorManager.class.getClassLoader();
url = cl.getResource(fileName);
}
if (url == null && formatName.equals("antlr")) {
rawError("ANTLR installation corrupted; cannot find ANTLR messages format file " + fileName);
panic();
}
else if (url == null) {
rawError("no such message format file " + fileName + " retrying with default ANTLR format");
setFormat("antlr"); // recurse on this rule, trying the default message format
return;
}
loadedFormat = new STGroupFile(url, "UTF-8", '<', '>');
loadedFormat.load();
loadedFormats.put(formatName, loadedFormat);
}
}
this.formatName = formatName;
this.format = loadedFormat;
if (!initSTListener.errors.isEmpty()) {View on GitHub (pinned to 7d5770395b)
Solutions
- Re-download the official antlr-4.x-complete.jar from maven central and replace the broken one
- Verify the jar contains org/antlr/v4/tool/templates/messages/formats/ group files: jar tf antlr-4.x-complete.jar | grep messages
- Check the build plugin/dependency did not shade or minimize-jar the ANTLR tool resources away
- If embedding the tool, ensure the context classloader can see ANTLR resources (Thread.currentThread().setContextClassLoader(...))
Example fix
# verify jar resources (before: missing -> corrupted) jar tf antlr-4.13.1-complete.jar | grep 'tool/templates/messages' # after: re-fetch the official artifact mvn org.apache.maven.plugins:maven-dependency-plugin:3.6.1:get \ -Dartifact=org.antlr:antlr4:4.13.1
Defensive patterns
Strategy: validation
Validate before calling
// verify the tool jar carries its message templates before invoking it
ClassLoader cl = ErrorManager.class.getClassLoader();
if (cl.getResource("org/antlr/v4/tool/templates/messages/formats/antlr.stg") == null) {
throw new IllegalStateException("antlr jar incomplete: missing messages format file");
} Prevention
- Use the official antlr-4.x-complete.jar from Maven Central
- Avoid shading/minimizing the ANTLR tool jar in build plugins
- Verify jar integrity with 'jar tf ... | grep messages' after any packaging change
When it happens
Trigger: Running the ANTLR Tool (antlr4 generation) where the resources directory is missing from the jar, a shaded/repackaged jar dropped the templates, or a custom classloader (e.g. in an app server or build plugin) fails to expose the resource.
Common situations: Corrupted download of antlr-4.x-complete.jar, wrong jar on classpath, overly aggressive shading/proguard stripping resources, or running the tool with a non-standard context classloader.
Related errors
- FileStream is only available when running in Node!
- ANTLR panic
- replace: range invalid: ${from}..${to}(size=${this.tokens.si
- replace op boundaries of ${rop} overlap with previous ${prev
- insert op ${iop} within boundaries of previous ${rop}
AI-assisted analysis of antlr/antlr4@7d5770395b (2026-08-14).
Data as JSON: /api/errors/bcca395c0eaafbd8.
Report an issue: GitHub.