{"record":{"id":"1bdf64c1d558be7c","repo":"pentaho/pentaho-kettle","slug":"repository-loadrepositorydirectory-errorloading-exception","errorCode":null,"errorMessage":"Repository.LoadRepositoryDirectory.ErrorLoading.Exception","messagePattern":"Repository\\.LoadRepositoryDirectory\\.ErrorLoading\\.Exception","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/repository/kdr/delegates/KettleDatabaseRepositoryDirectoryDelegate.java","lineNumber":129,"sourceCode":"      RowMetaAndData row = getDirectory( id_directory );\n      if ( row != null ) {\n        repositoryDirectory.setObjectId( id_directory );\n\n        // Content?\n        //\n        repositoryDirectory.setName( row.getString( \"DIRECTORY_NAME\", null ) );\n\n        // The sub-directories?\n        //\n        ObjectId[] subids = repository.getSubDirectoryIDs( repositoryDirectory.getObjectId() );\n        for ( int i = 0; i < subids.length; i++ ) {\n          RepositoryDirectory subdir = new RepositoryDirectory();\n          loadRepositoryDirectory( subdir, subids[i] );\n          repositoryDirectory.addSubdirectory( subdir );\n        }\n      }\n    } catch ( Exception e ) {\n      throw new KettleException( BaseMessages.getString(\n        PKG, \"Repository.LoadRepositoryDirectory.ErrorLoading.Exception\" ), e );\n    }\n  }\n\n  /*\n   * public synchronized RepositoryDirectory refreshRepositoryDirectoryTree() throws KettleException { try {\n   * RepositoryDirectory tree = new RepositoryDirectory(); loadRepositoryDirectory(tree, tree.getID());\n   * repository.setDirectoryTree(tree); return tree; } catch (KettleException e) { repository.setDirectoryTree( new\n   * RepositoryDirectory() ); throw new KettleException(\"Unable to read the directory tree from the repository!\", e); }\n   * }\n   */\n\n  private synchronized ObjectId insertDirectory( ObjectId id_directory_parent, RepositoryDirectoryInterface dir ) throws KettleException {\n    ObjectId id = repository.connectionDelegate.getNextDirectoryID();\n\n    String tablename = KettleDatabaseRepository.TABLE_R_DIRECTORY;\n    RowMetaAndData table = new RowMetaAndData();\n    table.addValue( new ValueMetaInteger(","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/repository/kdr/delegates/KettleDatabaseRepositoryDirectoryDelegate.java#L111-L147","documentation":"This is a wrapper KettleException thrown by KettleDatabaseRepositoryDirectoryDelegate.loadRepositoryDirectory when any exception occurs while loading a directory's metadata and children from the database repository. The original exception is attached as the cause, so the real failure (SQL error, connection loss, corrupt row) is inside it. The library throws it to normalize all database failures during directory-tree reads into the Kettle exception hierarchy.","triggerScenarios":"Calling loadRepositoryDirectory(id) / loadRepositoryDirectoryTree() / renameDirectory when the underlying repository.selectDirectory/getDirectoryIDs queries fail: invalid or nonexistent directory ObjectId, database connection dropped mid-query, schema mismatch, or corrupt r_directory rows.","commonSituations":"Repository database went down or connection timed out while browsing the directory tree; referencing a cached/stale ObjectId after another client deleted the directory; repository schema version mismatch after a Pentaho upgrade.","solutions":["Inspect e.getCause() for the real KettleDatabaseException/SQLException and fix that root cause first","Verify the directory ObjectId still exists (repository.getDirectoryIDs / directory tree refresh) before loading","Reconnect/reopen the repository connection and retry","Run repository connection tests and confirm the r_directory table exists and matches the installed schema version"],"exampleFix":"// before\nRepositoryDirectory dir = repository.loadRepositoryDirectoryTree();\n// after\ntry {\n  RepositoryDirectory dir = repository.loadRepositoryDirectoryTree();\n} catch ( KettleException e ) {\n  log.error( \"Directory load failed\", e.getCause() ); // inspect cause, reconnect/retry\n}","handlingStrategy":"try-catch","validationCode":"// pre-check: ensure the directory id resolves in a fresh tree\nRepositoryDirectoryInterface tree = repository.loadRepositoryDirectoryTree();\nif ( tree.findDirectory( dirId ) == null ) throw new IllegalStateException( \"Directory no longer exists\" );","typeGuard":"boolean directoryExists( Repository repo, ObjectId id ) {\n  try { return repo.getDirectoryIDs( RepoDirectoryId.ROOT ).stream().anyMatch( id::equals ); }\n  catch ( Exception e ) { return false; }\n}","tryCatchPattern":"try {\n  RepositoryDirectory dir = repository.loadRepositoryDirectoryTree();\n} catch ( KettleException e ) {\n  Throwable cause = e.getCause();\n  // retry once after reconnect if cause is KettleDatabaseException\n}","preventionTips":["Always inspect getCause() to find the real database error","Refresh the directory tree before operating on cached ObjectIds","Monitor repository DB connectivity; reconnect on failure","Keep repository schema upgraded to match the Kettle version"],"tags":["database","repository","directory-load","kettle-exception"],"backgroundTag":"database-query-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"}