{"record":{"id":"19a08808a435f88d","repo":"pentaho/pentaho-kettle","slug":"jobmeta-exception-unabletoloadjobfromxmlfile","errorCode":null,"errorMessage":"JobMeta.Exception.UnableToLoadJobFromXMLFile","messagePattern":"JobMeta\\.Exception\\.UnableToLoadJobFromXMLFile","errorType":"exception","errorClass":"KettleXMLException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/job/JobMeta.java","lineNumber":889,"sourceCode":"  public JobMeta( Bowl bowl, VariableSpace parentSpace, String fname, Repository rep, IMetaStore metaStore,\n      OverwritePrompter prompter ) throws KettleXMLException {\n    this.initializeVariablesFrom( parentSpace );\n    this.metaStore = metaStore;\n    setBowl( bowl );\n    try {\n      // OK, try to load using the VFS stuff...\n      Document doc = XMLHandler.loadXMLFile( KettleVFS.getInstance( bowl ).getFileObject( fname, this ) );\n      if ( doc != null ) {\n        // The jobnode\n        Node jobnode = XMLHandler.getSubNode( doc, XML_TAG );\n\n        loadXML( jobnode, fname, rep, metaStore, false, prompter );\n      } else {\n        throw new KettleXMLException(\n            BaseMessages.getString( PKG, \"JobMeta.Exception.ErrorReadingFromXMLFile\" ) + fname );\n      }\n    } catch ( Exception e ) {\n      throw new KettleXMLException(\n          BaseMessages.getString( PKG, \"JobMeta.Exception.UnableToLoadJobFromXMLFile\" ) + fname + \"]\", e );\n    }\n  }\n\n  /**\n   * Instantiates a new job meta.\n   *\n   * @param inputStream the input stream\n   * @param rep         the rep\n   * @param prompter    the prompter\n   * @throws KettleXMLException the kettle xml exception\n   */\n  public JobMeta( InputStream inputStream, Repository rep, OverwritePrompter prompter ) throws KettleXMLException {\n    this();\n    Document doc = XMLHandler.loadXMLFile( inputStream, null, false, false );\n    loadXML( XMLHandler.getSubNode( doc, JobMeta.XML_TAG ), rep, prompter );\n  }\n","sourceCodeStart":871,"sourceCodeEnd":907,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/job/JobMeta.java#L871-L907","documentation":"JobMeta throws this KettleXMLException when loading a job from an XML file fails for any reason: the file cannot be read/parsed, the root job node is missing, or an exception occurs while populating the metadata (nested exception 'e' carries the root cause). The message includes the file name in brackets to identify which job file failed.","triggerScenarios":"Calling JobMeta constructors or loadXML(String fname) with an unreadable, malformed, or non-job XML file; the inner loadXML call throws and the catch block wraps it with the 'JobMeta.Exception.UnableToLoadJobFromXMLFile' message plus the file name.","commonSituations":"Opening a .kjb file that was truncated or hand-edited into invalid XML; pointing at an XML file that is actually a transformation (.ktr) or export fragment; wrong file encoding or BOM; file locked or unreadable due to permissions; loading a job saved by a newer Pentaho version with unknown elements.","solutions":["Open the .kjb file and validate it as well-formed XML (xmllint or an XML editor); fix any malformed tags","Verify the file is a job export whose root node is <job>, not a transformation or unrelated XML","Check file read permissions and that the file is not empty or truncated","Inspect the chained cause exception ('Caused by') for the true root cause and fix that first","If the file came from a different PDI version, re-export it from the original tool or upgrade the runtime"],"exampleFix":"// before\nJobMeta jobMeta = new JobMeta(fileName, null, metaStore);\n// after\nFile f = new File(fileName);\nif (!f.isFile() || f.length() == 0) { throw new IllegalArgumentException(\"Missing/empty job file: \" + fileName); }\ntry {\n  JobMeta jobMeta = new JobMeta(fileName, null, metaStore);\n} catch (KettleXMLException e) {\n  log.error(\"Cannot load job \" + fileName, e); // inspect getCause()\n}","handlingStrategy":"try-catch","validationCode":"java.io.File f = new java.io.File(fname);\nif (!f.isFile() || f.length() == 0) throw new IllegalArgumentException(\"Job file missing or empty: \" + fname);\njavax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(f); // well-formedness pre-check","typeGuard":null,"tryCatchPattern":"try {\n  JobMeta jobMeta = new JobMeta(fname, rep, metaStore);\n} catch (KettleXMLException e) {\n  Throwable cause = e.getCause();\n  log.error(\"Failed to load job \" + fname + \": \" + (cause != null ? cause.getMessage() : e.getMessage()), e);\n}","preventionTips":["Keep .kjb files under version control so truncated/corrupt edits are detectable","Validate job XML after any hand-editing or templating step","Never point the loader at .ktr transformation files","Pin the PDI runtime version to match how jobs were exported"],"tags":["xml","job-meta","kettle","file-loading"],"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"}