{"record":{"id":"1177884a1d21d2e3","repo":"pentaho/pentaho-kettle","slug":"transmeta-exception-notvalidtransformationxml","errorCode":null,"errorMessage":"TransMeta.Exception.NotValidTransformationXML","messagePattern":"TransMeta\\.Exception\\.NotValidTransformationXML","errorType":"exception","errorClass":"KettleXMLException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/TransMeta.java","lineNumber":3094,"sourceCode":"      final FileObject transFile = KettleVFS.getInstance( bowl ).getFileObject( fname, parentVariableSpace );\n      if ( !transFile.exists() ) {\n        throw new KettleXMLException( BaseMessages.getString( PKG, \"TransMeta.Exception.InvalidXMLPath\", fname ) );\n      }\n      doc = XMLHandler.loadXMLFile( transFile );\n    } catch ( KettleXMLException ke ) {\n      // if we have a KettleXMLException, simply re-throw it\n      throw ke;\n    } catch ( KettleException | FileSystemException e ) {\n      throw new KettleXMLException( BaseMessages.getString(\n        PKG, \"TransMeta.Exception.ErrorOpeningOrValidatingTheXMLFile\", fname ), e );\n    }\n\n    if ( doc != null ) {\n      // Root node:\n      Node transnode = XMLHandler.getSubNode( doc, XML_TAG );\n\n      if ( transnode == null ) {\n        throw new KettleXMLException( BaseMessages.getString(\n          PKG, \"TransMeta.Exception.NotValidTransformationXML\", fname ) );\n      }\n\n      // Load from this node...\n      loadXML( transnode, fname, metaStore, rep, setInternalVariables, parentVariableSpace, prompter );\n\n    } else {\n      throw new KettleXMLException( BaseMessages.getString(\n        PKG, \"TransMeta.Exception.ErrorOpeningOrValidatingTheXMLFile\", fname ) );\n    }\n  }\n\n  /**\n   * Instantiates a new transformation meta-data object.\n   *\n   * @param xmlStream\n   *          the XML input stream from which to read the transformation definition\n   * @param fname","sourceCodeStart":3076,"sourceCodeEnd":3112,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/TransMeta.java#L3076-L3112","documentation":"TransMeta(String fname, ...) loads a transformation from an XML file. After parsing, it looks for the root <transformation> element via XMLHandler.getSubNode(doc, XML_TAG). If that element is missing, KettleXMLException with TransMeta.Exception.NotValidTransformationXML is thrown because the file, although well-formed XML, is not a Pentaho/Kettle transformation definition.","triggerScenarios":"Calling new TransMeta(fname) (or TransMeta.fromXML/TransMeta(...)) on an XML file whose root tag is not 'transformation' (e.g. a job .kjb file, a saved UI layout, arbitrary XML).","commonSituations":"Passing a .kjb job file where a .ktr transformation is expected; file renamed/corrupted; wrong file handed to the transformation loader; exporting the wrong artifact type.","solutions":["Verify the file is a transformation (.ktr) whose root element is <transformation>, not a job (.kjb) or other XML","Open the file in Spoon or inspect the first lines to confirm the root tag","Regenerate/export the transformation from Pentaho if it is corrupted or truncated"],"exampleFix":"// before\nTransMeta tm = new TransMeta(\"job.kjb\"); // throws NotValidTransformationXML\n// after\nTransMeta tm = new TransMeta(\"transformation.ktr\"); // root: <transformation>","handlingStrategy":"validation","validationCode":"boolean isTransformationXml(String path) throws Exception {\n  DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();\n  Document doc = f.newDocumentBuilder().parse(new File(path));\n  return doc.getDocumentElement().getTagName().equals(\"transformation\");\n}\nif (!isTransformationXml(fname)) throw new IllegalArgumentException(fname + \" is not a .ktr transformation\");","typeGuard":"if (doc == null || !\"transformation\".equals(doc.getDocumentElement().getTagName())) return false;","tryCatchPattern":"try {\n  TransMeta tm = new TransMeta(fname);\n} catch (KettleXMLException e) {\n  logger.error(\"Not a valid transformation XML: {}\", fname, e);\n  throw new IllegalArgumentException(\"Expected a .ktr transformation file\", e);\n}","preventionTips":["Keep .ktr and .kjb files in separate directories with correct extensions","Never hand-edit transformation XML without validating the root tag afterwards","Validate files with xmllint or a schema check before loading programmatically"],"tags":["xml","transformation","parsing"],"backgroundTag":"schema-validation-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"}