{"record":{"id":"19cb0d8de5e3fd96","repo":"pentaho/pentaho-kettle","slug":"unable-to-load-image-from-classpath-filename","errorCode":null,"errorMessage":"Unable to load image from classpath : '<fileName>'","messagePattern":"Unable to load image from classpath : '<fileName>'","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/core/gui/SwingDirectGC.java","lineNumber":270,"sourceCode":"      if ( inputStream == null ) {\n        try {\n          inputStream = new FileInputStream( \"/\" + fileName );\n        } catch ( FileNotFoundException ex ) {\n          // no need to fail\n        }\n      }\n      if ( inputStream == null ) {\n        inputStream = getClass().getResourceAsStream( fileName );\n      }\n      if ( inputStream == null ) {\n        inputStream = getClass().getResourceAsStream( \"/\" + fileName );\n      }\n      if ( inputStream != null ) {\n        try {\n          SvgImage svg = SvgSupport.loadSvgImage( inputStream );\n          image = new SwingUniversalImageSvg( svg );\n        } catch ( Exception ex ) {\n          throw new KettleException( \"Unable to load image from classpath : '\" + fileName + \"'\", ex );\n        } finally {\n          IOUtils.closeQuietly( inputStream );\n        }\n      }\n    }\n\n    if ( image == null ) {\n      fileName = SvgSupport.toPngName( fileName );\n\n      try {\n        inputStream = new FileInputStream( fileName );\n      } catch ( FileNotFoundException ex ) {\n        // no need to fail\n      }\n      if ( inputStream == null ) {\n        try {\n          inputStream = new FileInputStream( \"/\" + fileName );\n        } catch ( FileNotFoundException ex ) {","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/core/gui/SwingDirectGC.java#L252-L288","documentation":"In SwingDirectGC.getImageIcon, when SVG support is enabled and the name is an .svg file, SvgSupport.loadSvgImage(inputStream) is invoked; any exception while parsing the SVG is wrapped in KettleException(\"Unable to load image from classpath : '<fileName>'\", ex). Despite the wording, the stream here comes from FileInputStream on the given path, so the failure is usually a corrupt/unreadable SVG on disk.","triggerScenarios":"SVG support enabled (SvgSupport.isSvgEnabled() true) and fileName ends with an SVG extension, but loadSvgImage throws — corrupt SVG XML, file unreadable mid-read, unsupported SVG features, or a broken SVG renderer (e.g. missing BatX/SVGSalamander dependency).","commonSituations":"Deployments where the SVG rendering library is absent so SVG parsing fails; truncated or hand-edited .svg icon files; icons replaced with non-SVG content keeping the .svg extension.","solutions":["Read the wrapped cause (ex.getCause()) to see the real parse/IO error and fix the SVG file.","Validate the SVG opens in a browser/editor; re-export a clean SVG for the icon.","Disable SVG support (use PNG/BMP icons) if the SVG renderer dependency is unavailable in your deployment.","Check that the file at the path is readable by the process user."],"exampleFix":"// before (corrupt icon.svg on disk)\n// KettleException: Unable to load image from classpath : 'icon.svg'\n// after\n// replace icon.svg with a valid SVG, or switch to PNG:\nString fileName = \"icon.png\"; // skips the SVG branch","handlingStrategy":"try-catch","validationCode":"File svg = new File(fileName);\nif (!svg.isFile() || svg.length() == 0) throw new IOException(\"missing/empty svg: \" + fileName);\nif (!new String(java.nio.file.Files.readAllBytes(svg.toPath()), StandardCharsets.US_ASCII)\n      .startsWith(\"<?xml\") && !filesBytesStartsWith(svg, \"<svg\")) log.warn(\"file does not look like SVG\");","typeGuard":null,"tryCatchPattern":"try {\n  gc.getImageIcon(fileName);\n} catch (KettleException e) {\n  Throwable cause = e.getCause();\n  log.error(\"SVG load failed for \" + fileName + \": \" + cause, cause);\n  image = loadPngFallback(fileName);\n}","preventionTips":["Keep the SVG rendering library on the classpath in all deployments.","Validate SVG assets in CI (parse them headlessly before shipping).","Ship PNG fallbacks next to SVG icons.","Never hand-edit shipped SVGs without re-validating."],"tags":["gui","swing","svg","image-loading","kettle"],"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"}