pentaho/pentaho-kettle · error · KettleException
Error writing XML row :
Error message
Error writing XML row :
What it means
XMLOutput.writeRowToFile wraps any exception raised while writing one XML row (start/end element, characters, encoding) into this KettleException, including the offending row content via getInputRowMeta().getString(r). It indicates an I/O or serialization failure mid-row, typically from the underlying StAX writer or the output stream.
Solutions
- Check disk space and file permissions on the output file
- Enable 'Fast dump' vs formatted mode or sanitize field values to valid XML characters
- Verify the file encoding setting matches the data (e.g. UTF-8)
- Read the wrapped cause e and the printed Row to identify the offending value
Example fix
// before
String value = data.valueMeta.getString( valueData );
// after
String value = data.valueMeta.getString( valueData ).replaceAll("[\u0000-\u0008\u000B\u000C\u000E-\u001F]", ""); Defensive patterns
Strategy: try-catch
Validate before calling
// before run
java.io.File out = new java.io.File(filename);
if (out.getParentFile() != null && !out.getParentFile().canWrite()) throw new IllegalStateException("Output dir not writable");
if (out.getParentFile().getUsableSpace() < minBytes) throw new IllegalStateException("Low disk space"); Type guard
boolean writableTarget = new java.io.File(directory).canWrite();
Try / catch
try { writeRowToFile(row); } catch (KettleStepException|KettleException e) { log.error("XML row write failed: " + e.getCause(), e); } Prevention
- Monitor disk space on output directories
- Use UTF-8 encoding unless data dictates otherwise
- Sanitize control characters from string fields before XML output
- Route the offending row to an error handling stream
When it happens
Trigger: processRow -> writeRowToFile when the writer throws: disk full, file closed/removed, illegal XML characters in field values, encoding conversion errors, or stream closed by a concurrent error.
Common situations: Target filesystem full or quota exceeded; field data contains characters invalid in the target encoding; network drive disconnected mid-run.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- Error writing line :
- Unable to save to XML file '" + filename + "'
- AddSequenceMeta.Exception.ErrorLoadingStepInfo
- AggregateRowsMeta.Exception.UnableToLoadStepInfo
- AnalyticQueryMeta.Exception.UnableToLoadStepInfoFromXML
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/8d5abe0a0939d096.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/xml/core/src/main/java/org/pentaho/di/trans/steps/xmloutput/XMLOutput.java:213
ValueMetaInterface valueMeta = data.formatRowMeta.getValueMeta( data.fieldnrs[i] );
Object valueData = getNullIfValue( r[data.fieldnrs[i]], outputField.getNullString() );
String elementName = outputField.getElementName();
if ( Utils.isEmpty( elementName ) ) {
elementName = outputField.getFieldName();
}
if ( !( valueMeta.isNull( valueData ) && meta.isOmitNullValues() ) ) {
writeField( valueMeta, valueData, elementName );
}
}
}
}
data.writer.writeEndElement();
data.writer.writeCharacters( EOL );
} catch ( Exception e ) {
throw new KettleException( "Error writing XML row :" + e.toString() + Const.CR + "Row: "
+ getInputRowMeta().getString( r ), e );
}
incrementLinesOutput();
}
void writeRowAttributes( Object[] r ) throws KettleValueException, XMLStreamException {
for ( int i = 0; i < meta.getOutputFields().length; i++ ) {
XMLField xmlField = meta.getOutputFields()[i];
if ( xmlField.getContentType() == ContentType.Attribute ) {
ValueMetaInterface valueMeta = data.formatRowMeta.getValueMeta( data.fieldnrs[i] );
Object valueData = r[data.fieldnrs[i]];
String elementName = xmlField.getElementName();
if ( Utils.isEmpty( elementName ) ) {
elementName = xmlField.getFieldName();
}
View on GitHub (pinned to f3058517a1)