{"record":{"id":"4004ce587afae9a7","repo":"pentaho/pentaho-kettle","slug":"kettleexception-e-exceloutput","errorCode":null,"errorMessage":"KettleException( e )","messagePattern":"KettleException\\( e \\)","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/excel/core/src/main/java/org/pentaho/di/trans/steps/exceloutput/ExcelOutput.java","lineNumber":826,"sourceCode":"      InputStream imageStream = null;\n      try ( FileObject imageFile = KettleVFS.getInstance( getTransMeta().getBowl() )\n              .getFileObject( data.realHeaderImage ) ) {\n        if ( !imageFile.exists() ) {\n          throw new KettleException( BaseMessages.getString( PKG, \"ExcelInputLog.ImageFileNotExists\", data.realHeaderImage ) );\n        }\n        data.realHeaderImage = KettleVFS.getFilename( imageFile );\n        // Put an image\n        Dimension m = ExcelFontMap.getImageDimension( data.realHeaderImage );\n        data.headerImageWidth = m.getWidth() * 0.016;\n        data.headerImageHeight = m.getHeight() * 0.0625;\n\n        byte[] imageData = new byte[(int) imageFile.getContent().getSize()];\n        imageStream = KettleVFS.getInputStream( imageFile );\n        imageStream.read( imageData );\n\n        data.headerImage = new WritableImage( 0, 0, data.headerImageWidth, data.headerImageHeight, imageData );\n      } catch ( Exception e ) {\n        throw new KettleException( e );\n      }\n    }\n\n    // --- Set rows font\n    // Set font size\n    int rowFontSize = Const.toInt( environmentSubstitute( meta.getRowFontSize() ), ExcelOutputMeta.DEFAULT_FONT_SIZE );\n    // Set font name\n    FontName rowFontName = ExcelFontMap.getFontName( meta.getRowFontName() );\n\n    data.writableFont = new WritableFont( rowFontName, rowFontSize, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE );\n\n    // Row font color\n    Colour rowFontColour = ExcelFontMap.getColour( meta.getRowFontColor(), Colour.BLACK );\n    if ( !fontHeaderColour.equals( Colour.BLACK ) ) {\n      data.writableFont.setColour( rowFontColour );\n    }\n\n    // Set rows background color if needed","sourceCodeStart":808,"sourceCodeEnd":844,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/excel/core/src/main/java/org/pentaho/di/trans/steps/exceloutput/ExcelOutput.java#L808-L844","documentation":"Inside setFonts, after the header image is confirmed to exist, the step reads its bytes to build a WritableImage. Any exception during that sequence (getting content size, opening the VFS input stream, reading bytes) is rethrown as a bare KettleException with the original exception as cause.","triggerScenarios":"setFonts() (called from openNewFile()) fails at imageFile.getContent().getSize(), KettleVFS.getInputStream(imageFile), or imageStream.read(imageData) — e.g. VFS provider errors, size change between size query and read, or IO failure on the image file.","commonSituations":"Image on a network/SFTP share that drops mid-read; file truncated or locked by another process; VFS authentication failure when fetching the stream; image larger than memory assumptions; race where the file is deleted between the exists() check and the read.","solutions":["Inspect the cause's stack trace — the wrapper message carries no detail of its own.","Verify the header image is a readable, stable local file at execution time; copy it locally instead of reading from a network share.","Check VFS connection settings (credentials, timeout) if the image lives on a remote filesystem.","Ensure the file is not being modified/deleted concurrently between the exists() check and the read.","Test opening the image with a plain FileInputStream from the PDI host to isolate VFS vs. image problems."],"exampleFix":"// before: read without loop, assumes full read\nimageStream.read( imageData );\n// after: read fully and close properly\ntry ( InputStream in = KettleVFS.getInputStream( imageFile ) ) {\n  int off = 0, n;\n  while ( off < imageData.length && ( n = in.read( imageData, off, imageData.length - off ) ) >= 0 ) {\n    off += n;\n  }\n}","handlingStrategy":"try-catch","validationCode":"if ( !imageFile.exists() || imageFile.getContent().getSize() == 0 ) throw new KettleException( \"Header image unreadable: \" + imageFile.getName() );","typeGuard":null,"tryCatchPattern":"try { /* image load */ } catch ( KettleException e ) { logError( \"Image load failed: \" + e.getCause(), e ); }","preventionTips":["Keep header images on local, stable storage rather than network shares.","Copy the image before reading to avoid concurrent modification.","Confirm the image is a valid, non-empty file before configuring it."],"tags":["pentaho-kettle","excel-output","io","vfs","wrapped-exception"],"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"}