{"record":{"id":"9d7789db13c7817a","repo":"pentaho/pentaho-kettle","slug":"jobentrytruncatetables-unableloadxml","errorCode":null,"errorMessage":"JobEntryTruncateTables.UnableLoadXML","messagePattern":"JobEntryTruncateTables\\.UnableLoadXML","errorType":"exception","errorClass":"KettleXMLException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/job/entries/truncatetables/JobEntryTruncateTables.java","lineNumber":141,"sourceCode":"\n      String dbname = XMLHandler.getTagValue( entrynode, \"connection\" );\n      this.connection = DatabaseMeta.findDatabase( databases, dbname );\n      this.argFromPrevious = \"Y\".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, \"arg_from_previous\" ) );\n\n      Node fields = XMLHandler.getSubNode( entrynode, \"fields\" );\n\n      // How many field arguments?\n      int nrFields = XMLHandler.countNodes( fields, \"field\" );\n      allocate( nrFields );\n\n      // Read them all...\n      for ( int i = 0; i < nrFields; i++ ) {\n        Node fnode = XMLHandler.getSubNodeByNr( fields, \"field\", i );\n        this.arguments[i] = XMLHandler.getTagValue( fnode, \"name\" );\n        this.schemaname[i] = XMLHandler.getTagValue( fnode, \"schemaname\" );\n      }\n    } catch ( KettleException e ) {\n      throw new KettleXMLException( BaseMessages.getString( PKG, \"JobEntryTruncateTables.UnableLoadXML\" ), e );\n    }\n  }\n\n  public void loadRep( Repository rep, IMetaStore metaStore, ObjectId id_jobentry, List<DatabaseMeta> databases,\n    List<SlaveServer> slaveServers ) throws KettleException {\n    try {\n      connection = rep.loadDatabaseMetaFromJobEntryAttribute( id_jobentry, \"connection\", \"id_database\", databases );\n\n      this.argFromPrevious = rep.getJobEntryAttributeBoolean( id_jobentry, \"arg_from_previous\" );\n      // How many arguments?\n      int argnr = rep.countNrJobEntryAttributes( id_jobentry, \"name\" );\n      allocate( argnr );\n\n      // Read them all...\n      for ( int a = 0; a < argnr; a++ ) {\n        this.arguments[a] = rep.getJobEntryAttributeString( id_jobentry, a, \"name\" );\n        this.schemaname[a] = rep.getJobEntryAttributeString( id_jobentry, a, \"schemaname\" );\n      }","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/job/entries/truncatetables/JobEntryTruncateTables.java#L123-L159","documentation":"JobEntryTruncateTables.loadXML() wraps any KettleException raised while parsing the job entry's XML <fields> nodes into a KettleXMLException with the localized message 'JobEntryTruncateTables.UnableLoadXML'. It is thrown when the XML representation of the 'truncate tables' job entry cannot be read — typically a malformed or missing <field> sub-node. The original exception is preserved as the cause.","triggerScenarios":"Calling loadXML(...) with an XML node whose <fields> element or its <field> children are missing/malformed, so XMLHandler.getSubNodeByNr/getTagValue throws, or the declared nrFields does not match the actual number of <field> nodes.","commonSituations":"Hand-edited or truncated .kjb job files; XML produced by a different Pentaho/Kettle version with changed field names; corrupted repository-export XML; copy-paste errors in the field/schemaname attributes.","solutions":["Open the .kjb file in a text editor and fix or remove the malformed <field> entries under the truncate-tables job entry node.","Recreate the job entry in Spoon so a well-formed XML block is regenerated.","Check the cause chain (KettleXMLException.getCause()) to find the exact XMLHandler failure line.","Verify the file was not truncated or re-encoded (BOM/charset issues) during transfer between systems."],"exampleFix":"// before: hand-edited .kjb with missing <name> tag\n<field><schemaname>public</schemaname></field>\n// after\n<field><name>my_table</name><schemaname>public</schemaname></field>","handlingStrategy":"try-catch","validationCode":"// Validate the XML node before calling loadXML\nNode fields = XMLHandler.getSubNode(entrynode, \"fields\");\nif (fields == null) throw new KettleXMLException(\"Missing <fields> node\");\nint nr = XMLHandler.countNodes(fields, \"field\");\nfor (int i = 0; i < nr; i++) {\n  Node f = XMLHandler.getSubNodeByNr(fields, \"field\", i);\n  if (f == null || XMLHandler.getTagValue(f, \"name\") == null)\n    throw new KettleXMLException(\"Field \" + i + \" missing <name>\");\n}","typeGuard":"boolean isValidFieldsNode(Node entrynode) {\n  Node fields = XMLHandler.getSubNode(entrynode, \"fields\");\n  return fields != null && XMLHandler.countNodes(fields, \"field\") > 0;\n}","tryCatchPattern":"try {\n  jobEntry.loadXML(entrynode, databases, metaStore);\n} catch ( KettleXMLException e ) {\n  logError(\"Corrupt truncate-tables XML: \" + e.getCause().getMessage(), e);\n  // skip entry, load from repository, or abort the job load\n}","preventionTips":["Never hand-edit .kjb files; edit through Spoon.","Keep writer and reader Pentaho/Kettle versions aligned.","Keep .kjb files in version control to diff against known-good versions.","Validate XML well-formedness after any external transformation of job files."],"tags":["xml","serialization","kettle","job-entry"],"backgroundTag":"xml-parse-error","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"}