{"record":{"id":"1d68c90161913506","repo":"pentaho/pentaho-kettle","slug":"template-file-missing-data-realtemplatefilename","errorCode":null,"errorMessage":"Template file missing: \" + data.realTemplateFileName","messagePattern":"Template file missing: \" \\+ data\\.realTemplateFileName","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/excel/core/src/main/java/org/pentaho/di/trans/steps/excelwriter/ExcelWriterStep.java","lineNumber":882,"sourceCode":"      String templateExt = KettleVFS.getInstance( getTransMeta().getBowl() )\n        .getFileObject( data.realTemplateFileName ).getName().getExtension();\n      if ( !meta.getExtension().equalsIgnoreCase( templateExt ) ) {\n        throw new KettleException(\n            \"Template Format Mismatch: Template has extension: \" + templateExt + \", but output file has extension: \"\n                + meta.getExtension() + \". Template and output file must share the same format!\" );\n      }\n\n      if ( KettleVFS.getInstance( getTransMeta().getBowl() ).getFileObject( data.realTemplateFileName ).exists() ) {\n        // if the template exists just copy the template in place\n        copyFile( getTransMeta().getBowl(), KettleVFS.getInstance( getTransMeta().getBowl() )\n          .getFileObject( data.realTemplateFileName, getTransMeta() ), data.file );\n      } else {\n        // template is missing, log it and get out\n        if ( log.isBasic() ) {\n          logBasic( BaseMessages.getString( PKG, \"ExcelWriterStep.Log.TemplateMissing\", data.realTemplateFileName ) );\n        }\n        setErrors( 1 );\n        throw new KettleException( \"Template file missing: \" + data.realTemplateFileName );\n      }\n    } else {\n      // handle fresh file case, just create a fresh workbook\n      try ( Workbook wb = XLSX.equalsIgnoreCase( meta.getExtension() ) ? new XSSFWorkbook() : new HSSFWorkbook();\n          BufferedOutputStreamWithCloseDetection out =\n              new BufferedOutputStreamWithCloseDetection( KettleVFS.getInstance( getTransMeta().getBowl() )\n                .getOutputStream( data.file, false ) ) ) {\n        wb.createSheet( data.realSheetname );\n        wb.write( out );\n      }\n    }\n  }\n\n  private void openLine() {\n    if ( data.shiftExistingCells ) {\n      data.sheet.shiftRows( data.posY, Math.max( data.posY, data.sheet.getLastRowNum() ), 1 );\n    }\n  }","sourceCodeStart":864,"sourceCodeEnd":900,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/excel/core/src/main/java/org/pentaho/di/trans/steps/excelwriter/ExcelWriterStep.java#L864-L900","documentation":"With 'Use template' enabled, createFile() checks whether the template file exists via VFS. If it does not, it logs 'TemplateMissing' at basic level, sets the step error count, and throws KettleException(\"Template file missing: <path>\").","triggerScenarios":"Template file path (static or resolved from a field) points to a nonexistent file at createFile time: wrong path, file deleted, relative path resolving differently at runtime, or template not yet generated by an earlier step.","commonSituations":"Template stored on a network drive that is not mounted; relative paths broken when running in a different working directory; template generation step failed silently upstream; case-sensitive Linux filesystem vs Windows-style path casing.","solutions":["Verify the template file exists at the exact path shown in the message","Use an absolute path for the template filename","Check drive mounts/permissions if the template is on a network share","Ensure the step that generates the template ran before this step (ordering in the transformation)","Check filename casing on Linux filesystems"],"exampleFix":"// before\nString template = \"templates/report_template.xlsx\"; // relative, breaks in kitchen\n// after\nString template = \"/opt/pdi/templates/report_template.xlsx\"; // absolute path","handlingStrategy":"validation","validationCode":"String resolved = environmentSubstitute(templatePath);\nFile t = new File(resolved);\nif (!t.isFile()) throw new IllegalStateException(\"Template file missing: \" + t.getAbsolutePath());\nif (!t.canRead()) throw new IllegalStateException(\"Template not readable: \" + t.getAbsolutePath());","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use absolute template paths","On Linux, verify filename casing","Ensure upstream template-generation steps run first","Check network drive availability before scheduled runs"],"tags":["excel","template","file-not-found","kettle"],"backgroundTag":"file-not-found","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"}