pentaho/pentaho-kettle · error · KettleException
SharedOjects.WriteToFile.ErrorWritingFile
SharedOjects.WriteToFile.ErrorWritingFile
Error message
SharedOjects.WriteToFile.ErrorWritingFile
What it means
SharedObjects.writeToFile() wraps any IOException thrown while writing the shared objects XML file into a KettleException with localized message 'SharedOjects.WriteToFile.ErrorWritingFile'. Before throwing, it attempts to restore the original file from the .backup copy so the user's shared objects file (kettle.properties-style shared objects, e.g. databases/steps saved as shared) is not lost. The boolean flag indicates whether the backup was restored.
Solutions
- Check free disk space and free some if the volume is full
- Grant the running user write permission on the shared objects file and its directory (e.g. ~/.kettle)
- Verify the filesystem is mounted read-write; remount or fix container volume settings
- Restore manually from the .backup file next to the shared objects file if it is corrupted
- Check the wrapped cause (KettleException.getCause()) for the exact IOException
Example fix
// before
sharedObjects.saveToFile(); // throws KettleException on IO failure
// after
try {
sharedObjects.saveToFile();
} catch ( KettleException e ) {
boolean restored = e.getMessage().contains( "restored" ); // check log
logError( "Could not write shared objects file; backup restored=" + restored, e );
} Defensive patterns
Strategy: try-catch
Validate before calling
java.io.File f = new java.io.File( sharedObjects.getFilename() );
if ( !f.getParentFile().canWrite() || f.exists() && !f.canWrite() ) {
throw new IllegalStateException( "Cannot write shared objects file: " + f );
}
if ( f.getUsableSpace() < 1024 * 1024 ) {
throw new IllegalStateException( "Low disk space" );
} Try / catch
try {
sharedObjects.saveToFile();
} catch ( KettleException e ) {
Throwable root = e; while ( root.getCause() != null ) root = root.getCause();
logger.error( "Shared objects write failed (backup may have been restored): {}", root.getMessage(), e );
} Prevention
- Ensure the process user owns/can write ~/.kettle and the shared objects file
- Monitor free disk space on the volume holding the shared objects file
- Keep the .backup file next to the shared objects file intact
- In containers, mount the config directory read-write
When it happens
Trigger: Calling saveToFile() on a SharedObjects instance when the underlying file cannot be written: disk full, read-only filesystem, missing write permission on the file/directory, or the output stream failing mid-write.
Common situations: Running Spoon/Carte/PDI jobs whose user lacks write access to ~/.kettle or the shared-objects directory; read-only container filesystems; full disks during long transformation runs; antivirus/backup tools locking the shared.xml file on Windows.
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
- MailConnection.Error.WriteMboxFile
- Cannot open control file
- Cannot open data file
- ChangeFileEncoding.Error.CreatingFile
- Couldn't write to the database cache
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/4e6dcf0704894838.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/shared/SharedObjects.java:319
out = new PrintStream( outputStream );
out.print( XMLHandler.getXMLHeader( Const.XML_ENCODING ) );
out.println( "<" + XML_TAG + ">" );
Collection<SharedObjectInterface> collection = objectsMap.values();
for ( SharedObjectInterface sharedObject : collection ) {
String xmlContent = sharedObject.getXML();
out.println( xmlContent );
}
out.println( "</" + XML_TAG + ">" );
} catch ( Exception e ) {
// restore file if something wrong
boolean isRestored = false;
if ( backupFileName != null ) {
restoreFileFromBackup( backupFileName );
isRestored = true;
}
throw new KettleException(
BaseMessages.getString( PKG, "SharedOjects.WriteToFile.ErrorWritingFile", isRestored ), e );
} finally {
if ( out != null ) {
out.flush();
}
if ( out != null ) {
out.close();
}
if ( out != null ) {
outputStream.close();
}
}
}
private FileObject getFileObjectFromKettleVFS( String filename ) throws KettleFileException {
return KettleVFS.getInstance( DefaultBowl.getInstance() ).getFileObject( filename );
}
View on GitHub (pinned to f3058517a1)