{"record":{"id":"6c0b3996bc6a5984","repo":"pentaho/pentaho-kettle","slug":"sharedojects-errorwritingfile","errorCode":"SharedOjects.ErrorWritingFile","errorMessage":"${SharedOjects.ErrorWritingFile}","messagePattern":"\\$\\{SharedOjects\\.ErrorWritingFile\\}","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/shared/VfsSharedObjectsIO.java","lineNumber":91,"sourceCode":"      Optional<String> backupFileName = createOrGetFileBackup( fileObject );\n      writeToFile( fileObject, backupFileName );\n    } catch ( IOException ex ) {\n      throw new KettleException( ex );\n    }\n  }\n\n  private void writeToFile( FileObject fileObject, Optional<String> backupFileName )\n    throws IOException, KettleException {\n    try ( OutputStream outputStream = KettleVFS.getInstance( bowl ).getOutputStream( fileObject, false ) ) {\n      writeTo( outputStream );\n    } catch ( Exception e ) {\n      // restore file if something wrong\n      boolean isRestored = false;\n      if ( backupFileName.isPresent() ) {\n        restoreFileFromBackup( backupFileName.get() );\n        isRestored = true;\n      }\n      throw new KettleException( BaseMessages.getString( PKG, \"SharedOjects.ErrorWritingFile\", isRestored ), e );\n    }\n  }\n\n  /**\n   * Loads the shared objects in the map. The map will be of the form <String, Node>\n   * where key can be {\"connection\", \"slaveserver\", \"partitionschema\" or clusterschema\"} and\n   * value will be xml Node.\n   *\n   * @param pathToSharedObjectFile The path to the shared object file\n   * @throws KettleXMLException\n   */\n  private void loadSharedObjectNodeMap( String pathToSharedObjectFile ) throws KettleXMLException {\n\n    try {\n      // Get the FileObject\n      FileObject file = KettleVFS.getInstance( bowl ).getFileObject( pathToSharedObjectFile );\n\n      // If we have a shared file, load the content, otherwise, just keep this one empty","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/shared/VfsSharedObjectsIO.java#L73-L109","documentation":"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.","triggerScenarios":"Calling saveToFile/writeToFile when the underlying VFS file cannot be written (locked, read-only filesystem, network share unreachable, or IO error mid-write).","commonSituations":"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.","solutions":["Check the cause (KettleException.getCause()) to identify the underlying IOException and fix the file system/VFS problem (permissions, lock, connectivity).","Verify the backup file was restored (isRestored) and confirm the shared objects XML is intact before retrying.","Retry the save after restoring VFS connectivity or freeing the file lock.","Move the shared objects file to a reliable local path if the VFS location is chronically unavailable."],"exampleFix":"// before\nsharedObjectsIO.saveToFile(); // throws on VFS failure\n// after\ntry {\n  sharedObjectsIO.saveToFile();\n} catch ( KettleException e ) {\n  log.error( \"Failed writing shared objects file\", e.getCause() );\n  // ensure VFS target reachable / permissions OK, then retry\n}","handlingStrategy":"retry","validationCode":"FileObject f = VFS.getManager().resolveFile( sharedObjectsFile );\nif ( !f.exists() || !f.isWriteable() ) { /* fix path/permissions/connectivity first */ }","typeGuard":null,"tryCatchPattern":"try {\n  io.saveToFile();\n} catch ( KettleException e ) {\n  log.error( \"Shared objects write failed\", e.getCause() );\n  // verify backup restored, then retry once connectivity/locks are resolved\n}","preventionTips":["Prefer a local file path for shared objects when VFS is unreliable","Check VFS connectivity and file locks before saving","Monitor .backup file creation to detect partial writes"],"tags":["file-write-failed","io","vfs","shared-objects"],"backgroundTag":"file-write-failed","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"}