{"record":{"id":"3016b28e82c63cc6","repo":"pentaho/pentaho-kettle","slug":"sharedojects-readingfile-unexpectederror","errorCode":"SharedOjects.Readingfile.UnexpectedError","errorMessage":"SharedOjects.Readingfile.UnexpectedError","messagePattern":"SharedOjects\\.Readingfile\\.UnexpectedError","errorType":"exception","errorClass":"KettleXMLException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/shared/SharedObjects.java","lineNumber":178,"sourceCode":"            if ( nodeName.equals( StepMeta.XML_TAG ) ) {\n              StepMeta stepMeta = new StepMeta( node, privateDatabases, (IMetaStore) null );\n              stepMeta.setDraw( false ); // don't draw it, keep it in the tree.\n              isShared = stepMeta;\n            } else if ( nodeName.equals( PartitionSchema.XML_TAG ) ) {\n              isShared = new PartitionSchema( node );\n            } else if ( nodeName.equals( ClusterSchema.XML_TAG ) ) {\n              isShared = new ClusterSchema( node, privateSlaveServers );\n            }\n\n            if ( isShared != null ) {\n              isShared.setShared( true );\n              storeObject( isShared );\n            }\n          }\n        }\n      }\n    } catch ( Exception e ) {\n      throw new KettleXMLException( BaseMessages.getString( PKG, \"SharedOjects.Readingfile.UnexpectedError\",\n        sharedObjectsFile ), e );\n    }\n  }\n\n  public static final String createFilename( String sharedObjectsFile ) {\n    String filename;\n    if ( Utils.isEmpty( sharedObjectsFile ) ) {\n      // First fallback is the environment/kettle variable ${KETTLE_SHARED_OBJECTS}\n      // This points to the file\n      filename = Variables.getADefaultVariableSpace().getVariable( Const.KETTLE_SHARED_OBJECTS );\n\n      // Last line of defence...\n      if ( Utils.isEmpty( filename ) ) {\n        filename = Const.getSharedObjectsFile();\n      }\n    } else {\n      filename = sharedObjectsFile;\n    }","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/shared/SharedObjects.java#L160-L196","documentation":"SharedObjects constructor throws this KettleXMLException when reading/parsing the shared-objects XML file fails unexpectedly. All shareable objects already parsed remain, but the whole read is aborted and wrapped with the message keyed SharedOjects.Readingfile.UnexpectedError (note the bundle key's typo 'Ojects'), including the file name and original cause.","triggerScenarios":"Constructing SharedObjects where the XML file exists but SAX parsing fails: malformed/corrupt XML, unsupported root content, IO error mid-read, or an unexpected exception while storing an object (storeObject throwing a non-KettleXMLException type).","commonSituations":"shared.xml truncated by a previous crash or concurrent write; hand-edited shared objects file with invalid XML; version mismatch where the file contains entries an older/newer Kettle build cannot store; read permissions on the file.","solutions":["Validate/repair the shared-objects XML file (open it in an XML editor); restore from backup or delete to regenerate","Check e.getCause() for the exact SAX/IO error","Ensure the file is not being written concurrently by another Kettle instance","Verify read permissions and that the file path (sharedObjectsFile) is correct"],"exampleFix":"// before\nSharedObjects so = new SharedObjects(transMeta.getFilename());\n// after\nFile f = new File(sharedObjectsFile);\nif (f.exists() && !XMLHandler.isValid(f)) {\n  LOG.warn(\"Corrupt shared objects file \" + f + \", starting fresh\");\n  f.renameTo(new File(f.getParent(), \"shared.xml.corrupt\"));\n}\nSharedObjects so = new SharedObjects(sharedObjectsFile);","handlingStrategy":"try-catch","validationCode":"File f = new File(sharedObjectsFile);\nif (f.exists() && !isWellFormedXml(f)) {\n  LOG.warn(\"Corrupt shared-objects file: \" + f);\n}\n// isWellFormedXml: parse with a DocumentBuilder to check well-formedness","typeGuard":null,"tryCatchPattern":"try {\n  SharedObjects so = new SharedObjects(sharedObjectsFile);\n} catch (KettleXMLException e) {\n  LOG.error(\"Failed to read \" + sharedObjectsFile + \", cause: \" + e.getCause(), e);\n  // fall back to empty/default shared objects or restore backup\n}","preventionTips":["Back up shared.xml before running jobs that modify shared objects","Prevent concurrent Kettle instances writing the same shared-objects file","Validate XML after manual edits","Check read permissions and correct path before construction"],"tags":["shared-objects","xml-parse","kettle","file-read"],"backgroundTag":"json-parse-error","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"}