quarkusio/quarkus · error · IOException
Failed to read model
Error message
Failed to read model
What it means
MojoUtils.readPom(File) wraps any non-IO runtime failure from Maven.readModel into an IOException with message 'Failed to read model'. It indicates the pom.xml could not be parsed into a Maven Model (malformed XML, unreadable file, unsupported model).
Source
Thrown at independent-projects/tools/devtools-common/src/main/java/io/quarkus/maven/utilities/MojoUtils.java:173
* @param dependencies The plugin extensions
* @return The plugin instance
*/
public static Plugin plugin(String groupId, String artifactId, String version, List<Dependency> dependencies) {
Plugin plugin = new Plugin();
plugin.setArtifactId(artifactId);
plugin.setGroupId(groupId);
plugin.setVersion(version);
plugin.setDependencies(dependencies);
return plugin;
}
public static Model readPom(final File pom) throws IOException {
try {
return Maven.readModel(pom.toPath());
} catch (UncheckedIOException e) {
throw e.getCause();
} catch (RuntimeException e) {
throw new IOException("Failed to read model", e.getCause());
}
}
public static Model readPom(final InputStream resourceAsStream) throws IOException {
try (InputStream is = resourceAsStream) {
return Maven.readModel(is);
} catch (UncheckedIOException e) {
throw e.getCause();
} catch (RuntimeException e) {
throw new IOException("Failed to read model", e.getCause());
}
}
public static String[] readGavFromPom(final InputStream resourceAsStream) throws IOException {
Model model = readPom(resourceAsStream);
return new String[] { model.getGroupId(), model.getArtifactId(), model.getVersion() };
}
View on GitHub (pinned to e1c734241f)
Solutions
- Verify the file path points to an existing pom.xml
- Validate the XML is well-formed (open in an editor or run mvn help:effective-pom)
- Check file read permissions for the process user
- Inspect the chained cause (getCause) for the underlying parse error
Example fix
// before
Model m = MojoUtils.readPom(new File("src/pom.xml")); // wrong path
// after
File pom = new File("pom.xml");
if (!pom.isFile()) throw new IllegalStateException("pom.xml missing");
Model m = MojoUtils.readPom(pom); Defensive patterns
Strategy: validation
Validate before calling
if (pom == null || !pom.isFile() || !pom.canRead()) {
throw new IllegalStateException("pom.xml missing or unreadable: " + pom);
} Try / catch
try {
Model m = MojoUtils.readPom(pomFile);
} catch (IOException e) {
throw new UncheckedIOException("Cannot parse " + pomFile + ": check XML validity", e);
} Prevention
- Confirm the pom path exists and is a file before reading
- Keep pom.xml XML well-formed; run mvn help:effective-pom in CI to catch corruption
- Always log the chained cause for diagnosis
- Handle encoding consistently (UTF-8) across the project
When it happens
Trigger: Calling MojoUtils.readPom(File) on a file that is missing, unreadable, or not a well-formed pom.xml; Maven.readModel throws a RuntimeException whose cause is chained.
Common situations: Corrupted or hand-edited pom.xml with invalid XML, wrong file path passed in, encoding problems (invalid bytes for declared charset), or a truncated file.
Related errors
- Unable to render all config
- Unable to create directory: ${directory}
- Unable to collect the target directories
- Unable to read the template: ${template}
- Unable to close InputStream for template: ${template}
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/c0bcecc2d61983c0.
Report an issue: GitHub.