quarkusio/quarkus · error · IOException
Failed to parse POM
Error message
Failed to parse POM
What it means
ModelUtils.readModel(InputStream) parses a POM with MavenXpp3Reader. If the stream is not well-formed XML (XmlPullParserException), it is rethrown as IOException("Failed to parse POM", e). It means the pom.xml content itself is malformed, not that the file is missing.
Source
Thrown at independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/ModelUtils.java:261
}
final Properties props = new Properties();
try (BufferedReader reader = Files.newBufferedReader(propsPath)) {
props.load(reader);
}
return props;
}
public static Model readModel(final Path pomXml) throws IOException {
Model model = readModel(Files.newInputStream(pomXml));
model.setPomFile(pomXml.toFile());
return model;
}
public static Model readModel(InputStream stream) throws IOException {
try (InputStream is = stream) {
return new MavenXpp3Reader().read(is);
} catch (XmlPullParserException e) {
throw new IOException("Failed to parse POM", e);
}
}
public static void persistModel(Path pomFile, Model model) throws IOException {
final MavenXpp3Writer xpp3Writer = new MavenXpp3Writer();
try (BufferedWriter pomFileWriter = Files.newBufferedWriter(pomFile)) {
xpp3Writer.write(pomFileWriter, model);
}
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Open the pom.xml at the reported path and fix the XML syntax; run `mvn validate` or `xmllint --noout pom.xml` to confirm it parses.
- If merge conflict markers are present, resolve the merge and commit a clean pom.xml.
- Restore a corrupted/truncated pom.xml (git checkout -- pom.xml or rebuild it).
- Ensure the correct file path is being passed to readModel.
Example fix
// before: conflicted pom.xml <<<<<<< HEAD <version>1.0.0</version> ======= <version>2.0.0</version> >>>>>>> feature // after: resolved <version>2.0.0</version>
Defensive patterns
Strategy: validation
Validate before calling
static void validatePomXml(Path pom) throws IOException {
try {
new javax.xml.parsers.DocumentBuilderFactory().newInstance()
.newDocumentBuilder().parse(pom.toFile());
} catch (Exception e) {
throw new IOException("Malformed POM XML: " + pom + " - " + e.getMessage(), e);
}
} Try / catch
try {
Model model = ModelUtils.readModel(pomStream);
} catch (IOException e) {
if (e.getCause() instanceof XmlPullParserException) {
throw new IllegalStateException("Fix XML syntax in the POM: " + e.getCause().getMessage());
}
throw e;
} Prevention
- Run `xmllint --noout pom.xml` or `mvn validate` after hand-editing a POM.
- Resolve all merge conflicts in pom.xml before building.
- Keep XML editors configured for UTF-8 without stray BOM issues.
- Restore corrupted pom.xml files from version control rather than hand-fixing bytes.
When it happens
Trigger: Calling ModelUtils.readModel(Path) or readModel(InputStream) on a pom.xml containing XML syntax errors: unclosed tags, invalid characters/encoding, garbage bytes, truncated file, HTML instead of XML, or reading a non-XML file path by mistake.
Common situations: A merge conflict left conflict markers (<<<<<<<) in pom.xml; an interrupted build/write truncated the file; manual edits broke a tag; wrong file passed (e.g. a .txt or log file); encoding mismatches (BOM, non-UTF-8 bytes).
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Unable to parse pom file: ${pom}
- Failed to determine groupId for project model
- Failed to determine version for project model
- Failed to load POM from
- Could not resolve POM for
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/ace9837dddce34d1.
Report an issue: GitHub.