{"record":{"id":"a6898e5db3be4006","repo":"pentaho/pentaho-kettle","slug":"xmljoin-exception-fieldnotfound","errorCode":null,"errorMessage":"XMLJoin.Exception.FieldNotFound","messagePattern":"XMLJoin\\.Exception\\.FieldNotFound","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/xml/core/src/main/java/org/pentaho/di/trans/steps/xmljoin/XMLJoin.java","lineNumber":102,"sourceCode":"      // get the first line from the target row set\n      Object[] rTarget = getRowFrom( data.TargetRowSet );\n\n      if ( rTarget == null ) { // nothing to do\n        logBasic( BaseMessages.getString( PKG, \"XMLJoin.NoRowsFoundInTarget\" ) );\n        setOutputDone();\n        return false;\n      }\n\n      // get target xml\n      String[] target_field_names = data.TargetRowSet.getRowMeta().getFieldNames();\n      for ( int i = 0; i < target_field_names.length; i++ ) {\n        if ( meta.getTargetXMLfield().equals( target_field_names[i] ) ) {\n          target_field_id = i;\n        }\n      }\n      // Throw exception if target field has not been found\n      if ( target_field_id == -1 ) {\n        throw new KettleException( BaseMessages.getString( PKG, \"XMLJoin.Exception.FieldNotFound\", meta\n            .getTargetXMLfield() ) );\n      }\n\n      data.outputRowMeta = data.TargetRowSet.getRowMeta().clone();\n      meta.getFields( getTransMeta().getBowl(), data.outputRowMeta, getStepname(),\n          new RowMetaInterface[] { data.TargetRowSet.getRowMeta() }, null, getTransMeta(), repository, metaStore );\n      data.outputRowData = rTarget.clone();\n\n      // get the target xml structure and create a DOM\n      String strTarget = (String) rTarget[target_field_id];\n      // parse the XML as a W3C Document\n\n      InputSource inputSource = new InputSource( new StringReader( strTarget ) );\n\n      data.XPathStatement = meta.getTargetXPath();\n      try {\n        DocumentBuilder builder = XMLParserFactoryProducer.createSecureDocBuilderFactory().newDocumentBuilder();\n        data.targetDOM = builder.parse( inputSource );","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/xml/core/src/main/java/org/pentaho/di/trans/steps/xmljoin/XMLJoin.java#L84-L120","documentation":"XMLJoin.processRow() searches the target stream's row fields for the field named by meta.getTargetXMLfield(). If no field matches (target_field_id stays -1), it throws a KettleException with the localized message XMLJoin.Exception.FieldNotFound. The XMLJoin step cannot locate the configured target XML field in the incoming target rows.","triggerScenarios":"Running the XMLJoin step when the 'Target XML field' configured in the step dialog does not exist in the fields of the target input stream — e.g. the upstream step was renamed, removed, or outputs different columns than when the step was configured.","commonSituations":"Renaming/deleting the target XML field in an upstream step (Get XML Data, Add XML, etc.) without updating XMLJoin; reusing a transformation where field names changed; case-sensitivity mismatch in field names.","solutions":["Open the XMLJoin step dialog and set 'Target XML field' to a field that exists in the target stream.","Preview the target stream's output (preview in Spoon) and confirm the exact field name and case.","Update the upstream step so it produces the expected XML field (e.g. re-add the XML field in the source step).","Re-run field discovery: delete and re-configure the XMLJoin mapping after upstream changes."],"exampleFix":"// before: step configured with a field the upstream no longer emits\nmeta.setTargetXMLfield(\"xml_content_old\");\n// after: use the actual field name emitted upstream\nmeta.setTargetXMLfield(\"xml_content\");","handlingStrategy":"validation","validationCode":"// Before running, confirm the configured field exists in the target stream\nRowMetaInterface targetRowMeta = targetStep.getStepMetaInterface().getFields(...);\nif (!targetRowMeta.searchFieldMeta(meta.getTargetXMLfield()).isPresent()) {\n  throw new IllegalStateException(\"Target XML field missing: \" + meta.getTargetXMLfield());\n}","typeGuard":null,"tryCatchPattern":"try {\n  xmlJoinStep.processRow();\n} catch (KettleException e) {\n  if (e.getMessage().contains(\"FieldNotFound\")) {\n    log.error(\"Configured XML field no longer exists in stream; re-check upstream steps\", e);\n  }\n}","preventionTips":["Preview upstream output in Spoon after any upstream change.","Treat field names as a contract; rename fields with a Select values step consistently.","Re-open and re-save the XMLJoin dialog after changing upstream steps.","Watch field-name case when configuring steps."],"tags":["kettle","xmljoin","field-mapping"],"backgroundTag":"record-not-found","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"}