{"record":{"id":"42bb3b3971aa2ff3","repo":"pentaho/pentaho-kettle","slug":"unable-to-load-image-from-classpath-filename-swinggc","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/SwingGC.java","lineNumber":276,"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":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/core/gui/SwingGC.java#L258-L294","documentation":"In SwingGC.getImageIcon, the SVG branch (SvgSupport enabled, .svg name) wraps any exception from SvgSupport.loadSvgImage as KettleException(\"Unable to load image from classpath : '<fileName>'\", ex). The input comes from FileInputStream on the given name, so parsing/IO failures on the SVG file surface under this misleading 'classpath' message.","triggerScenarios":"SVG-enabled environment, .svg fileName, and loadSvgImage throws — malformed SVG XML, unreadable file, or missing/broken SVG rendering library.","commonSituations":"Missing SVG renderer dependency in headless or minimal deployments; corrupt or wrong-content .svg icons; SVGs using unsupported features.","solutions":["Check the wrapped cause to identify the parse vs IO failure and fix the SVG file.","Validate the SVG externally (browser/editor) and re-export if needed.","Disable SVG support and ship PNG icons if the renderer library is unavailable.","Confirm file read permissions on the icon path."],"exampleFix":"// before\n// broken logo.svg -> KettleException: Unable to load image from classpath : 'logo.svg'\n// after\n// use a valid SVG or fall back:\nString fileName = svgIsValid ? \"logo.svg\" : \"logo.png\";","handlingStrategy":"try-catch","validationCode":"File svg = new File(fileName);\nif (!svg.isFile() || svg.length() == 0) { fileName = PNG_FALLBACK; }\nelse if (!looksLikeSvg(svg)) { fileName = PNG_FALLBACK; }","typeGuard":null,"tryCatchPattern":"try {\n  image = gc.getImageIcon(fileName);\n} catch (KettleException e) {\n  Throwable cause = e.getCause();\n  log.error(\"SVG parse failed for \" + fileName + \": \" + cause, cause);\n  image = loadPngFallback(fileName);\n}","preventionTips":["Ensure SVG rendering dependencies ship with the application.","Validate all SVG assets at build time.","Keep PNG fallbacks alongside SVG icons.","Watch for deployments that strip optional jars (renderer libraries)."],"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"}