pentaho/pentaho-kettle · error · KettleException

SharedOjects.ErrorWritingFile

SharedOjects.ErrorWritingFile

Error message

${SharedOjects.ErrorWritingFile}

What it means

VfsSharedObjectsIO.writeToFile fails while persisting the shared objects XML file over a VFS connection, restoring the backup first if one exists. The original IOException is wrapped in a KettleException whose message is the localized 'SharedOjects.ErrorWritingFile' key, indicating the shared-objects file could not be written.

Solutions

  1. Check the cause (KettleException.getCause()) to identify the underlying IOException and fix the file system/VFS problem (permissions, lock, connectivity).
  2. Verify the backup file was restored (isRestored) and confirm the shared objects XML is intact before retrying.
  3. Retry the save after restoring VFS connectivity or freeing the file lock.
  4. Move the shared objects file to a reliable local path if the VFS location is chronically unavailable.

Example fix

// before
sharedObjectsIO.saveToFile(); // throws on VFS failure
// after
try {
  sharedObjectsIO.saveToFile();
} catch ( KettleException e ) {
  log.error( "Failed writing shared objects file", e.getCause() );
  // ensure VFS target reachable / permissions OK, then retry
}
Defensive patterns

Strategy: retry

Validate before calling

FileObject f = VFS.getManager().resolveFile( sharedObjectsFile );
if ( !f.exists() || !f.isWriteable() ) { /* fix path/permissions/connectivity first */ }

Try / catch

try {
  io.saveToFile();
} catch ( KettleException e ) {
  log.error( "Shared objects write failed", e.getCause() );
  // verify backup restored, then retry once connectivity/locks are resolved
}

Prevention

When it happens

Trigger: Calling saveToFile/writeToFile when the underlying VFS file cannot be written (locked, read-only filesystem, network share unreachable, or IO error mid-write).

Common situations: Saving shared DB connections/kettle.properties-style shared objects to a network/FTP/VFS location that went offline; file locked by another process; insufficient write permission on the shared XML file.

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


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/6c0b3996bc6a5984. Report an issue: GitHub.

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/shared/VfsSharedObjectsIO.java:91

      Optional<String> backupFileName = createOrGetFileBackup( fileObject );
      writeToFile( fileObject, backupFileName );
    } catch ( IOException ex ) {
      throw new KettleException( ex );
    }
  }

  private void writeToFile( FileObject fileObject, Optional<String> backupFileName )
    throws IOException, KettleException {
    try ( OutputStream outputStream = KettleVFS.getInstance( bowl ).getOutputStream( fileObject, false ) ) {
      writeTo( outputStream );
    } catch ( Exception e ) {
      // restore file if something wrong
      boolean isRestored = false;
      if ( backupFileName.isPresent() ) {
        restoreFileFromBackup( backupFileName.get() );
        isRestored = true;
      }
      throw new KettleException( BaseMessages.getString( PKG, "SharedOjects.ErrorWritingFile", isRestored ), e );
    }
  }

  /**
   * Loads the shared objects in the map. The map will be of the form <String, Node>
   * where key can be {"connection", "slaveserver", "partitionschema" or clusterschema"} and
   * value will be xml Node.
   *
   * @param pathToSharedObjectFile The path to the shared object file
   * @throws KettleXMLException
   */
  private void loadSharedObjectNodeMap( String pathToSharedObjectFile ) throws KettleXMLException {

    try {
      // Get the FileObject
      FileObject file = KettleVFS.getInstance( bowl ).getFileObject( pathToSharedObjectFile );

      // If we have a shared file, load the content, otherwise, just keep this one empty

View on GitHub (pinned to f3058517a1)