{"record":{"id":"4ab0db916a4740dd","repo":"pentaho/pentaho-kettle","slug":"error-0002-cannot-load-job-from-repository-4ab0db","errorCode":"ERROR_0002_Cannot_Load_Job_From_Repository","errorMessage":"JobEntryCheckDbConnections.ERROR_0002_Cannot_Load_Job_From_Repository","messagePattern":"JobEntryCheckDbConnections\\.ERROR_0002_Cannot_Load_Job_From_Repository","errorType":"error_code","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/core/impl/src/main/java/org/pentaho/di/job/entries/checkdbconnection/JobEntryCheckDbConnections.java","lineNumber":246,"sourceCode":"\n  public void loadRep( Repository rep, IMetaStore metaStore, ObjectId id_jobentry, List<DatabaseMeta> databases,\n    List<SlaveServer> slaveServers ) throws KettleException {\n    try {\n      // How many connections?\n      int argnr = rep.countNrJobEntryAttributes( id_jobentry, \"id_database\" );\n      connections = new DatabaseMeta[argnr];\n      waitfors = new String[argnr];\n      waittimes = new int[argnr];\n      // Read them all...\n      for ( int a = 0; a < argnr; a++ ) {\n        connections[a] =\n          rep.loadDatabaseMetaFromJobEntryAttribute( id_jobentry, \"connection\", a, \"id_database\", databases );\n        waitfors[a] = rep.getJobEntryAttributeString( id_jobentry, a, \"waitfor\" );\n        waittimes[a] =\n          getWaitByCode( Const.NVL( rep.getJobEntryAttributeString( id_jobentry, a, \"waittime\" ), \"\" ) );\n      }\n    } catch ( KettleException dbe ) {\n      throw new KettleException( BaseMessages.getString(\n        PKG, \"JobEntryCheckDbConnections.ERROR_0002_Cannot_Load_Job_From_Repository\", \"\" + id_jobentry, dbe\n          .getMessage() ) );\n    }\n  }\n\n  public void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_job ) throws KettleException {\n    try {\n      // save the arguments...\n      if ( connections != null ) {\n        for ( int i = 0; i < connections.length; i++ ) {\n          rep.saveDatabaseMetaJobEntryAttribute(\n            id_job, getObjectId(), i, \"connection\", \"id_database\", connections[i] );\n\n          rep.saveJobEntryAttribute( id_job, getObjectId(), i, \"waittime\", getWaitTimeCode( waittimes[i] ) );\n          rep.saveJobEntryAttribute( id_job, getObjectId(), i, \"waitfor\", waitfors[i] );\n        }\n      }\n    } catch ( KettleDatabaseException dbe ) {","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/core/impl/src/main/java/org/pentaho/di/job/entries/checkdbconnection/JobEntryCheckDbConnections.java#L228-L264","documentation":"loadRep throws KettleException with ERROR_0002 when loading the CheckDbConnections entry from the repository fails. It wraps repository read errors (including loadDatabaseMetaFromJobEntryAttribute failing to resolve the connection) and includes id_jobentry and the DB error message.","triggerScenarios":"rep.loadDatabaseMetaFromJobEntryAttribute or getJobEntryAttributeString throwing because the referenced connection id no longer exists in R_DATABASE, or the repository connection fails.","commonSituations":"Jobs moved between repositories where database connections were not migrated; deleted shared connections; repository schema drift after upgrade.","solutions":["Re-create or re-import the missing database connection so the stored id_database resolves.","Check the wrapped dbe message for the SQL failure and repair the repository DB connection.","Re-save the job entry so connection attributes are rewritten against current R_DATABASE rows.","Run repository upgrade scripts after a Pentaho version change."],"exampleFix":"// before\nconnections[a] = rep.loadDatabaseMetaFromJobEntryAttribute( id_jobentry, \"connection\", a, \"id_database\", databases );\n// after\nDatabaseMeta db = rep.loadDatabaseMetaFromJobEntryAttribute( id_jobentry, \"connection\", a, \"id_database\", databases );\nconnections[a] = db != null ? db : DatabaseMeta.findDatabase( databases, fallbackName );","handlingStrategy":"validation","validationCode":"// confirm all referenced connections still exist in the target repository\nList<DatabaseMeta> dbs = rep.readDatabases();\nfor ( String connName : storedConnectionNames ) {\n  if ( DatabaseMeta.findDatabase( dbs, connName ) == null ) {\n    throw new IllegalStateException( \"connection missing: \" + connName );\n  }\n}","typeGuard":null,"tryCatchPattern":"try { entry.loadRep( rep, metaStore, id_jobentry, databases, slaveServers ); } catch ( KettleException e ) { logError( \"ERROR_0002 for \" + id_jobentry + \": \" + e.getMessage(), e ); }","preventionTips":["Export/import shared connections when moving jobs between repositories.","Never delete database connections referenced by job entries.","Run repository upgrade scripts after version changes."],"tags":["repository","database","connection-not-found","persistence"],"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"}