{"record":{"id":"d6b19ca8e579d6c7","repo":"pentaho/pentaho-kettle","slug":"error-reading-information-from-resource","errorCode":null,"errorMessage":"Error reading information from resource","messagePattern":"Error reading information from resource","errorType":"exception","errorClass":"KettleXMLException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/xml/XMLHandler.java","lineNumber":725,"sourceCode":"    DocumentBuilder db;\n    Document doc;\n\n    try {\n      // Check and open XML document\n      dbf = XMLParserFactoryProducer.createSecureDocBuilderFactory();\n      db = dbf.newDocumentBuilder();\n      InputStream inputStream = resource.openStream();\n      try {\n        doc = db.parse( inputStream );\n      } catch ( IOException ef ) {\n        throw new KettleXMLException( ef );\n      } finally {\n        inputStream.close();\n      }\n\n      return doc;\n    } catch ( Exception e ) {\n      throw new KettleXMLException( \"Error reading information from resource\", e );\n    }\n  }\n\n  /**\n   * Load a String into an XML document using the cached default DocumentBuilder.\n   * Uses ThreadLocal-cached DocumentBuilder to avoid expensive factory creation (~60% overhead reduction).\n   * This is the most common path for XML string parsing.\n   *\n   * Configuration: namespaceAware=false, deferNodeExpansion=true\n   *\n   * @param string The XML text to load into a document\n   * @return the parsed Document\n   * @throws KettleXMLException if parsing fails\n   */\n  public static Document loadXMLString( String string ) throws KettleXMLException {\n    return loadXMLString( DEFAULT_BUILDER_CACHE.get(), string );\n  }\n","sourceCodeStart":707,"sourceCodeEnd":743,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/xml/XMLHandler.java#L707-L743","documentation":"The File-based loadXMLFile(File) overload reads the file via its URI and wraps any exception during stream open/parse/close in a KettleXMLException with message \"Error reading information from resource\". Like the URL variant, the true cause is preserved in the chained exception.","triggerScenarios":"XMLHandler.loadXMLFile(File) where resource.toURI().toURL() stream fails to open (missing file, no read permission) or the parser rejects the content (malformed XML, wrong encoding).","commonSituations":"Plugin or metadata files with unreadable permissions, invalid characters in file paths breaking URI conversion, corrupt XML files, BOM or encoding mismatches (e.g. file saved as UTF-16 but declared UTF-8).","solutions":["Check the file exists and is readable (canRead()) before loading.","Validate the XML content and its declared encoding; re-save as clean UTF-8 without BOM if needed.","Inspect e.getCause() for the underlying SAX/IO error.","Confirm the path has no characters that break URI conversion (spaces are OK, but '#' or '%' are not)."],"exampleFix":"// before\nDocument doc = XMLHandler.loadXMLFile(new File(path));\n// after\nFile f = new File(path);\nif (!f.isFile() || !f.canRead()) throw new KettleException(\"Cannot read \" + path);\ntry {\n  Document doc = XMLHandler.loadXMLFile(f);\n} catch (KettleXMLException e) {\n  throw new KettleException(\"Bad XML in \" + path + \": \" + e.getCause(), e);\n}","handlingStrategy":"validation","validationCode":"File f = new File(path);\nif (!f.isFile() || !f.canRead()) throw new KettleException(\"Unreadable: \" + path);","typeGuard":"boolean isReadableXml(File f) {\n  return f != null && f.isFile() && f.canRead();\n}","tryCatchPattern":"try {\n  doc = XMLHandler.loadXMLFile(file);\n} catch (KettleXMLException e) {\n  throw new KettleException(\"Invalid XML resource \" + file + \": \" + e.getCause(), e);\n}","preventionTips":["Check exists/canRead before parsing","Save XML as clean UTF-8 without BOM","Avoid reserved URI characters (#, %) in paths"],"tags":["xml","parsing","file"],"backgroundTag":"file-read-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}