pentaho/pentaho-kettle · error · KettleFileException
Exception reading line using NIO:
Error message
Exception reading line using NIO:
What it means
FixedInput.readOneRow catches any exception while reading/parsing one fixed-width line via NIO and rethrows it as a KettleFileException with this message plus e.toString(). It indicates the NIO file read or line conversion failed mid-processing, not a field mapping issue.
Solutions
- Fix the step's line length / buffer size settings so fileSize is an exact multiple of the line size
- Check the chained exception for I/O vs decode errors and repair the source file (CRLF issues, truncation)
- Re-transfer the file in binary mode and verify expected file size
- Open the file in the step's preview to confirm the layout matches before running the full transformation
Example fix
// before fileSize = file.length(); // may include trailing partial line // after long lines = file.length() / lineLength; fileSize = lines * lineLength; // ignore trailing partial bytes
Defensive patterns
Strategy: validation
Validate before calling
// validate file before running the transformation
long size = new File( filename ).length();
if ( lineLength <= 0 || size % lineLength != 0 ) {
throw new IllegalStateException( "File size " + size + " not a multiple of line length " + lineLength );
} Try / catch
try {
trans.execute( null );
} catch ( KettleException e ) {
if ( e.getMessage().startsWith( "Exception reading line using NIO" ) ) {
// fix file/line-length config and retry
}
} Prevention
- Match the step's line length exactly to the file layout
- Transfer files in binary mode to avoid CRLF changes
- Preview a few rows before full runs
- Check file size vs expected record count
When it happens
Trigger: Reading a fixed-width file whose byte size is not a multiple of the line length, an I/O error on the underlying channel, or charset/decode errors during ByteBuffer-to-string conversion in processRow.
Common situations: Files transferred in text mode with altered line endings or trailing partial lines; wrong 'line length' setting in the Fixed file input step so the buffer math breaks; file truncated or locked by another process.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- GroupBy.Exception.UnableToCloseInputStream
- GroupBy.Exception.UnableToReadBackRowFromTemporaryFile
- JsonOutput.Error.OpenNewFile
- JsonOutput.Error.Writing
- API coding error: please specify the conversion metadata…
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/94d945adda6dfdc5.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/fixedinput/FixedInput.java:228
// CR + Line feed in the worst case.
//
if ( data.byteBuffer[data.startBuffer] == '\n' || data.byteBuffer[data.startBuffer] == '\r' ) {
data.startBuffer++;
if ( data.byteBuffer[data.startBuffer] == '\n' || data.byteBuffer[data.startBuffer] == '\r' ) {
data.startBuffer++;
}
}
data.endBuffer = data.startBuffer;
}
incrementLinesInput();
return outputRowData;
} catch ( Exception e ) {
throw new KettleFileException( "Exception reading line using NIO: " + e.toString(), e );
}
}
private FileInputStream getFileInputStream( URL url ) throws FileNotFoundException {
return new FileInputStream( FileUtils.toFile( url ) );
}
public boolean init( StepMetaInterface smi, StepDataInterface sdi ) {
meta = (FixedInputMeta) smi;
data = (FixedInputData) sdi;
if ( super.init( smi, sdi ) ) {
try {
data.preferredBufferSize = Integer.parseInt( environmentSubstitute( meta.getBufferSize() ) );
data.lineWidth = Integer.parseInt( environmentSubstitute( meta.getLineWidth() ) );
data.filename = environmentSubstitute( meta.getFilename() );
View on GitHub (pinned to f3058517a1)