{"record":{"id":"38f18bbcb92bc130","repo":"pentaho/pentaho-kettle","slug":"xmlhandler-errorcheckingfileexistence","errorCode":"XMLHandler.errorCheckingFileExistence","errorMessage":"${XMLHandler.errorCheckingFileExistence}","messagePattern":"\\$\\{XMLHandler\\.errorCheckingFileExistence\\}","errorType":"exception","errorClass":"KettleXMLException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/xml/XMLHandler.java","lineNumber":1299,"sourceCode":"      t.transform( new DOMSource( node ), new StreamResult( sw ) );\n    } catch ( Exception e ) {\n      throw new KettleXMLException( \"Unable to format Node as XML\", e );\n    }\n    return sw.toString();\n  }\n\n  /**\n   * <p>Checks if a given {@link FileObject} instance corresponds to an existing file.</p>\n   *\n   * @param fileObject the {@link FileObject} instance to check\n   * @return <code>true</code> if the file exists, <code>false</code> otherwise\n   * @throws KettleXMLException if an error occurred while checking\n   */\n  public static boolean checkFile( FileObject fileObject ) throws KettleXMLException {\n    try {\n      return fileObject != null && fileObject.exists() && fileObject.isFile();\n    } catch ( FileSystemException e ) {\n      throw new KettleXMLException( BaseMessages.getString(\n        PKG, \"XMLHandler.errorCheckingFileExistence\", fileObject.toString() ), e );\n    }\n  }\n}\n\n/**\n * Handle external references and return an empty dummy document.\n *\n * @author jb\n * @since 2007-12-21\n */\nclass DTDIgnoringEntityResolver implements EntityResolver {\n  private static final Log log = LogFactory.getLog( DTDIgnoringEntityResolver.class );\n  @Override\n  public InputSource resolveEntity( String publicID, String systemID ) throws IOException {\n    log.info( \"Public-ID: \" + publicID );\n    log.info( \"System-ID: \" + systemID );\n    return new InputSource( new ByteArrayInputStream( \"<?xml version='1.0' encoding='UTF-8'?>\".getBytes() ) );","sourceCodeStart":1281,"sourceCodeEnd":1317,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/xml/XMLHandler.java#L1281-L1317","documentation":"checkFile(FileObject) returns whether the FileObject exists and is a file; if the VFS layer itself fails during the exists()/isFile() probe (FileSystemException), it throws KettleXMLException with the localized message XMLHandler.errorCheckingFileExistence including the file path. It distinguishes 'cannot even check' from 'file absent'.","triggerScenarios":"XMLHandler.checkFile(FileObject) where fileObject.exists() or isFile() throws FileSystemException: unreachable remote filesystem (SFTP/HTTP VFS provider), invalid URI scheme, closed/broken VFS manager, permission issues at the provider level.","commonSituations":"Remote VFS endpoints (SFTP host down, expired credentials), invalid VFS URIs (sftp:// with wrong syntax), network partitions during job startup, VFS plugins missing.","solutions":["Inspect the chained FileSystemException for the provider-level error; test the URI with the standalone VFS/CLI tool.","Validate the VFS URI scheme and syntax (e.g. sftp://user:host/path vs correct sftp://host/path).","Check network connectivity and credentials for remote filesystems.","Treat checkFile failure as 'unknown state' and retry with backoff for transient network problems."],"exampleFix":"// before\nboolean ok = XMLHandler.checkFile(KettleVFS.getFileObject(uri));\n// after\nboolean ok;\ntry {\n  ok = XMLHandler.checkFile(KettleVFS.getFileObject(uri));\n} catch (KettleXMLException e) {\n  log.warn(\"Cannot verify \" + uri + \": \" + e.getCause());\n  ok = false;\n}","handlingStrategy":"try-catch","validationCode":"try { fo.exists(); } catch (FileSystemException e) { /* VFS provider broken — fix URI/network first */ }","typeGuard":"boolean canProbe(FileObject fo) {\n  try { fo.exists(); return true; } catch (FileSystemException e) { return false; }\n}","tryCatchPattern":"try {\n  ok = XMLHandler.checkFile(fo);\n} catch (KettleXMLException e) {\n  log.warn(\"Cannot verify file \" + fo + \": \" + e.getCause());\n  ok = false; // unknown state, treat as missing\n}","preventionTips":["Validate VFS URI scheme/syntax before use","Precheck remote endpoints (SFTP/HTTP) for reachability","Treat check exceptions as unknown, not as 'file absent'"],"tags":["vfs","filesystem","io"],"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"}