karatelabs/karate · warning
Failed to load pom:
Error message
Failed to load pom:
What it means
`karate run` optionally loads a pom.xml (via KaratePom.load) to augment classpath/config resolution. If parsing fails, the CLI prints 'Failed to load pom: <message>' as a warning and continues the run without the pom data; the exception is not rethrown. Malformed or unsupported pom structure degrades the run but does not abort it.
Solutions
- Read the appended e.getMessage() in the warning to identify the parse failure
- Validate the pom.xml with `mvn -q validate` or an XML parser and fix the malformed section
- Move/rename the invalid pom.xml out of the run directory if it is not needed
- Regenerate the pom (e.g. re-run the failed Maven build) and rerun `karate run`
Example fix
// before <project><build></project> <!-- truncated pom --> // after mvn -q validate # fix XML, then karate run # "pom.xml loaded"
Defensive patterns
Strategy: validation
Validate before calling
// before karate run
python3 -c "import xml.dom.minidom,sys; xml.dom.minidom.parse('pom.xml')" && echo 'pom XML valid' || echo 'pom malformed' Try / catch
karate run ... 2>&1 | tee run.log; grep 'Failed to load pom' run.log && echo 'pom ignored — fix pom.xml'
Prevention
- Keep pom.xml well-formed (validate with `mvn -q validate`)
- Don't leave truncated poms from interrupted builds — regenerate them
- Only point Karate at real Maven project directories
- Treat the warning as a prompt to fix, since pom-derived config was skipped
When it happens
Trigger: Running `karate run` in a directory (or with a resolved path) containing a pom.xml that is unparseable XML or structurally invalid for KaratePom.load — e.g. truncated file, wrong root element, encoding issues.
Common situations: Partial/failed Maven build leaving a corrupt pom; pointing Karate at a non-Maven project's XML file named pom.xml; pom generated by a tool with features KaratePom doesn't understand.
Understand the failure class
Background: "Config file not found": what it means and how to fix it in docker-sync, Maven, Vagrant, Turborepo and other tools — this error's family across 60 libraries.
Related errors
AI-assisted analysis of karatelabs/karate@a22eb90246 (2026-09-12).
Data as JSON: /api/errors/fbcfa236d915fc93.
Report an issue: GitHub.
Appendix: source
Thrown at karate-core/src/main/java/io/karatelabs/cli/RunCommand.java:350
}
private void loadPom() {
String file = pomFile != null ? pomFile : DEFAULT_POM_FILE;
Path pomPath;
// If workdir specified, look for pom there
if (workingDir != null) {
pomPath = Path.of(workingDir).resolve(file);
} else {
pomPath = Path.of(file);
}
if (Files.exists(pomPath)) {
try {
pom = KaratePom.load(pomPath);
Console.println(Console.info(pomPath.getFileName() + " loaded"));
} catch (Exception e) {
Console.println(Console.warn("Failed to load pom: " + e.getMessage()));
}
}
}
private List<String> resolvePaths() {
List<String> combined = new ArrayList<>();
if (paths != null) {
combined.addAll(paths);
}
if (pathOptions != null) {
combined.addAll(pathOptions);
}
if (!combined.isEmpty()) {
return combined;
}
if (pom != null && !pom.getPaths().isEmpty()) {
return pom.getPaths();
}View on GitHub (pinned to a22eb90246)