{"record":{"id":"2db996f7c24b1bbd","repo":"pentaho/pentaho-kettle","slug":"unable-to-read-file-filename","errorCode":null,"errorMessage":"Unable to read file '' + fileName + ''","messagePattern":"Unable to read file '' \\+ fileName \\+ ''","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/util/EnvUtil.java","lineNumber":60,"sourceCode":"   * @param fileName\n   *          the relative name of the properties file in the users kettle directory.\n   * @return the map of properties.\n   */\n  public static Properties readProperties( final String fileName ) throws KettleException {\n    if ( !new File( fileName ).exists() ) {\n      return readPropertiesByFullPath( Const.getKettleDirectory() + Const.FILE_SEPARATOR + fileName );\n    }\n    return readPropertiesByFullPath( fileName );\n  }\n\n  private static Properties readPropertiesByFullPath( final String fileName ) throws KettleException {\n    Properties props = new Properties();\n    InputStream is = null;\n    try {\n      is = new FileInputStream( fileName );\n      props.load( is );\n    } catch ( IOException ioe ) {\n      throw new KettleException( \"Unable to read file '\" + fileName + \"'\", ioe );\n    } finally {\n      if ( is != null ) {\n        try {\n          is.close();\n        } catch ( IOException e ) {\n          // ignore\n        }\n      }\n    }\n    return props;\n  }\n\n  /**\n   * Adds the kettle properties the the global system properties.\n   *\n   * @throws KettleException\n   *           in case the properties file can't be read.\n   */","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/util/EnvUtil.java#L42-L78","documentation":"EnvUtil.readPropertiesByFullPath loads a properties file from disk via FileInputStream; any IOException while opening or reading is wrapped in a KettleException with message \"Unable to read file '<fileName>'\". It is used by EnvUtil.readProperties to load environment/property files for Kettle initialization.","triggerScenarios":"readProperties(fileName) called with a path that does not exist, lacks read permission, is a directory, or fails mid-read (I/O error). Note the exception message in the index shows quoting artifacts, but the actual message interpolates the real file path.","commonSituations":"Missing kettle.properties or custom env file at the referenced path; wrong working directory for relative paths; read-permission problems under restricted service accounts.","solutions":["Verify the file exists at the exact path passed (use absolute paths)","Check read permissions for the process user","Confirm the path is a regular file, not a directory","Call EnvUtil.readProperties with the correct KETTLE_HOME-relative location"],"exampleFix":"// before\nEnvUtil.readProperties(\"kettle.properties\"); // relative, wrong cwd\n// after\nFile f = new File(System.getenv(\"KETTLE_HOME\"), \"kettle.properties\");\nif (!f.isFile()) { throw new FileNotFoundException(f.getAbsolutePath()); }\nEnvUtil.readProperties(f.getAbsolutePath());","handlingStrategy":"try-catch","validationCode":"File f = new File(fileName);\nif (!f.isFile() || !f.canRead()) { throw new IllegalArgumentException(\"Cannot read properties file: \" + f.getAbsolutePath()); }","typeGuard":"static boolean isReadableFile(String p) { File f = new File(p); return f.isFile() && f.canRead(); }","tryCatchPattern":"try {\n  EnvUtil.readProperties(fileName);\n} catch (KettleException e) {\n  LOG.error(\"Failed to load properties from {}: {}\", fileName, e.getCause().getMessage());\n  throw new IllegalStateException(\"Missing environment configuration\", e);\n}","preventionTips":["Use absolute paths or resolve against KETTLE_HOME explicitly","Check file existence/permissions during deployment/health checks","Package default properties as a classpath fallback"],"tags":["file-io","properties","env"],"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"}