{"record":{"id":"9167d1328655bdee","repo":"quarkusio/quarkus","slug":"failed-to-parse-webfragment","errorCode":null,"errorMessage":"Failed to parse ${webFragment}","messagePattern":"Failed to parse (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"extensions/undertow/deployment/src/main/java/io/quarkus/undertow/deployment/WebXmlParsingBuildStep.java","lineNumber":138,"sourceCode":"        List<WebFragmentMetaData> webFragments = new ArrayList<>();\n        for (ApplicationArchive archive : applicationArchivesBuildItem.getAllArchives()) {\n            archive.accept(tree -> {\n                Path webFragment = tree.getPath(WEB_FRAGMENT_XML);\n                if (webFragment != null && Files.isRegularFile(webFragment)) {\n                    try (InputStream is = Files.newInputStream(webFragment)) {\n                        final XMLInputFactory inputFactory = XMLInputFactory.newInstance();\n                        inputFactory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);\n                        inputFactory.setXMLResolver(NoopXMLResolver.create());\n                        XMLStreamReader xmlReader = inputFactory.createXMLStreamReader(is);\n\n                        WebFragmentMetaData webFragmentMetaData = WebFragmentMetaDataParser.parse(xmlReader,\n                                PropertyReplacers.resolvingExpressionReplacer(new MPConfigExpressionResolver()));\n                        webFragments.add(webFragmentMetaData);\n\n                    } catch (XMLStreamException e) {\n                        throw new RuntimeException(\"Failed to parse \" + webFragment + \" \" + e.getLocation(), e);\n                    } catch (IOException e) {\n                        throw new RuntimeException(\"Failed to parse \" + webFragment, e);\n                    }\n                }\n            });\n        }\n        return webFragments;\n    }\n\n}\n","sourceCodeStart":120,"sourceCodeEnd":147,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/undertow/deployment/src/main/java/io/quarkus/undertow/deployment/WebXmlParsingBuildStep.java#L120-L147","documentation":"Thrown by WebXmlParsingBuildStep while reading a web-fragment.xml during a Quarkus build. The file exists but cannot be parsed as valid XML (XMLStreamException) or opened/read (IOException). Quarkus re-throws it as a RuntimeException naming the offending fragment and XML location.","triggerScenarios":"A dependency JAR's META-INF/web-fragment.xml (or a project's one on the web-fragment path) is malformed, contains invalid XML characters/encoding, or the file is unreadable/truncated inside the JAR.","commonSituations":"Corrupt JAR in local Maven repo; hand-edited web-fragment.xml with a syntax error; wrong encoding (e.g. UTF-8 BOM issues); a legacy war-style library bundled in a Quarkus build.","solutions":["Open the fragment path shown in the message and fix/validate its XML syntax","Verify the JAR is not corrupt: `unzip -t app.jar` or delete and re-download the dependency from the local repo","If the fragment is from a third-party dependency, exclude it (`mvn dependency:exclude`) or pin a fixed version","Check the file encoding matches the XML declaration (add explicit encoding to the declaration)"],"exampleFix":"// before (malformed web-fragment.xml)\n<web-fragment>\n  <servlet><servlet-name>A</servlet-name></servlet>\n</web-fragment\n// after\n<web-fragment version=\"4.0\" xmlns=\"http://xmlns.jcp.org/xml/ns/javaee\">\n  <servlet><servlet-name>A</servlet-name><servlet-class>com.acme.A</servlet-class></servlet>\n</web-fragment>","handlingStrategy":"validation","validationCode":"// validate bundled web-fragment.xml before build\ntry (InputStream is = new ZipFile(new File(\"app.jar\")).getInputStream(new ZipEntry(\"META-INF/web-fragment.xml\"))) {\n    DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(is); // throws if malformed\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate XML resources in CI before packaging","Keep dependency JARs verified (mvn -U / checksum checks)","Avoid hand-editing XML inside JARs"],"tags":["quarkus","xml-parsing","build-time","web-fragment"],"backgroundTag":"xml-parse-error","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}