{"record":{"id":"07e084f2008cc301","repo":"apache/hadoop","slug":"unable-to-create-saxparser","errorCode":null,"errorMessage":"Unable to create SAXParser","messagePattern":"Unable to create SAXParser","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsBlobClient.java","lineNumber":1985,"sourceCode":"          if (!XML_TAG_HDI_PERMISSION.equalsIgnoreCase(entry.getKey())) {\n            value = encodeMetadataAttribute(value);\n          }\n        } catch (UnsupportedEncodingException e) {\n          throw new InvalidAbfsRestOperationException(e);\n        }\n        metadataRequestHeaders.add(new AbfsHttpHeader(key, value));\n      }\n    }\n    return metadataRequestHeaders;\n  }\n\n  private final ThreadLocal<SAXParser> saxParserThreadLocal = ThreadLocal.withInitial(() -> {\n    SAXParserFactory factory = SAXParserFactory.newInstance();\n    factory.setNamespaceAware(true);\n    try {\n      return factory.newSAXParser();\n    } catch (SAXException e) {\n      throw new RuntimeException(\"Unable to create SAXParser\", e);\n    } catch (ParserConfigurationException e) {\n      throw new RuntimeException(\"Check parser configuration\", e);\n    }\n  });\n\n  /**\n   * This will filter out all the rename pending json files in listing output.\n   * @param listResultSchema List of entries returned by Blob Endpoint.\n   * @param uri URI to be used for path conversion.\n   * @return List of entries after removing duplicates.\n   * @throws IOException if path conversion fails.\n   */\n  @VisibleForTesting\n  public ListResponseData filterRenamePendingFiles(\n      BlobListResultSchema listResultSchema, URI uri) throws IOException {\n    List<VersionedFileStatus> fileStatuses = new ArrayList<>();\n    Map<Path, Integer> renamePendingJsonPaths = new HashMap<>();\n","sourceCodeStart":1967,"sourceCodeEnd":2003,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsBlobClient.java#L1967-L2003","documentation":"A RuntimeException raised inside a per-thread SAXParser initializer in AbfsBlobClient. The first time a thread parses a blob-endpoint XML response (e.g. list containers / list paths), SAXParserFactory.newSAXParser() threw a SAXException, meaning the JAXP parser implementation on the classpath is broken or conflicting and no parser could be constructed for that thread.","triggerScenarios":"First blob-endpoint XML-listing operation on a given thread when the JAXP factory fails to produce a parser — typically duplicate or incompatible xerces / xml-apis / xml-parser jars on the classpath, a shading step overwriting META-INF/services entries, or a -Djavax.xml.parsers.SAXParserFactory system property pointing at a broken factory.","commonSituations":"Application assemblies that shade in an old Xerces; app servers or frameworks bundling their own XML parser; JVMs with a corrupted or stripped JAXP implementation; CI images with unusual JDK distributions.","solutions":["Run mvn dependency:tree -Dincludes=xerces,xml-apis,xml-apis-ext and exclude duplicate parser jars so exactly one implementation remains.","Remove javax.xml.parsers.SAXParserFactory system properties / JVM flags that select a custom factory.","If shading, verify META-INF/services/javax.xml.parsers.SAXParserFactory is preserved or removed, never replaced by an incompatible provider.","Sanity-check the runtime: a small main() calling SAXParserFactory.newInstance().newSAXParser() must succeed before Hadoop Azure is used."],"exampleFix":"<!-- before: old xerces shaded in transitively -->\n<dependency>\n  <groupId>com.example</groupId>\n  <artifactId>legacy-soap</artifactId>\n</dependency>\n<!-- after -->\n<dependency>\n  <groupId>com.example</groupId>\n  <artifactId>legacy-soap</artifactId>\n  <exclusions>\n    <exclusion><groupId>xerces</groupId><artifactId>xercesImpl</artifactId></exclusion>\n    <exclusion><groupId>xml-apis</groupId><artifactId>xml-apis</artifactId></exclusion>\n  </exclusions>\n</dependency>","handlingStrategy":"try-catch","validationCode":"try {\n  SAXParserFactory.newInstance().newSAXParser();\n} catch (Exception e) {\n  throw new IllegalStateException(\"Broken JAXP classpath for Hadoop Azure\", e);\n}","typeGuard":null,"tryCatchPattern":"try {\n  return blobClient.listContainers(prefix, token, tracingContext);\n} catch (RuntimeException ex) {\n  if (ex.getCause() instanceof SAXException) {\n    throw new IllegalStateException(\"XML parser unavailable — fix xerces/xml-apis conflicts\", ex);\n  }\n  throw ex;\n}","preventionTips":["Keep exactly one XML parser implementation on the classpath; exclude transitive xerces/xml-apis duplicates.","Do not set -Djavax.xml.parsers.SAXParserFactory to custom factories on Hadoop nodes.","After shading, verify JAXP META-INF/services files are intact.","Add a startup self-check that constructs a SAXParser before any Azure job starts."],"tags":["azure","abfs","xml","sax","jaxp","classpath"],"backgroundTag":"xml-parser-configuration","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}