{"record":{"id":"a843ad3bbefedd82","repo":"pentaho/pentaho-kettle","slug":"transmeta-exception-erroropeningorvalidatingthexmlfile","errorCode":null,"errorMessage":"TransMeta.Exception.ErrorOpeningOrValidatingTheXMLFile","messagePattern":"TransMeta\\.Exception\\.ErrorOpeningOrValidatingTheXMLFile","errorType":"exception","errorClass":"KettleXMLException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/TransMeta.java","lineNumber":3085,"sourceCode":"      if ( bowl != null ) {\n        setBowl( bowl );\n      }\n      if ( parentVariableSpace == null ) {\n        parentVariableSpace = new Variables();\n        // load globals\n        parentVariableSpace.initializeVariablesFrom( null );\n      }\n\n      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 ) );","sourceCodeStart":3067,"sourceCodeEnd":3103,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/TransMeta.java#L3067-L3103","documentation":"A KettleXMLException (message key TransMeta.Exception.ErrorOpeningOrValidatingTheXMLFile, with fname substituted) thrown when the transformation file exists but XMLHandler.loadXMLFile fails — the file cannot be opened, read, or parsed as XML. The underlying KettleException/FileSystemException is chained as the cause.","triggerScenarios":"new TransMeta(bowl, fname, ...) where the file exists but is unreadable, locked, not valid XML, or has an encoding/BOM problem causing XMLHandler.loadXMLFile(transFile) to throw.","commonSituations":"Truncated or partially written .ktr files; files with wrong encoding or invalid characters; permission errors on read; the path points to a directory or binary file instead of XML; VFS access issues on network mounts.","solutions":["Check the chained cause (e.getCause()) for the precise parse or IO error","Validate the file with an XML parser (xmllint) to confirm well-formedness","Verify read permissions on the file and that it is a file, not a directory","Re-export or re-save the transformation from Spoon","Confirm file encoding (UTF-8) and remove stray BOMs/binary content"],"exampleFix":"// before: loading possibly corrupt file directly\nTransMeta tm = new TransMeta(bowl, fname, metaStore, null, true, vars, null);\n// after: pre-validate\nDocument doc = XMLHandler.loadXMLFile(fname); // surface parse errors early with clear message\nif (doc == null) throw new KettleException(\"Not valid XML: \" + fname);\nTransMeta tm = new TransMeta(bowl, fname, metaStore, null, true, vars, null);","handlingStrategy":"validation","validationCode":"Document doc = XMLHandler.loadXMLFile(fname);\nif (doc == null) throw new KettleException(\"File is not well-formed XML: \" + fname);","typeGuard":null,"tryCatchPattern":"try { new TransMeta(bowl, fname, ...); } catch (KettleXMLException e) { log.error(\"Could not open/parse trans XML: \" + fname + \" cause=\" + e.getCause(), e); }","preventionTips":["Pre-validate .ktr files with an XML parser in CI","Guard against truncated file writes/transfer","Verify file permissions and encoding before loading"],"tags":["kettle","transformation","xml-parse","file-read"],"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"}