{"record":{"id":"42907f91612f3d80","repo":"pentaho/pentaho-kettle","slug":"error-0016-could-not-get-repository-instance","errorCode":"ERROR_0016_COULD_NOT_GET_REPOSITORY_INSTANCE","errorMessage":"RepositoryConnectionUtils.ERROR_0016_COULD_NOT_GET_REPOSITORY_INSTANCE","messagePattern":"RepositoryConnectionUtils\\.ERROR_0016_COULD_NOT_GET_REPOSITORY_INSTANCE","errorType":"error_code","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/repository/RepositoryConnectionUtils.java","lineNumber":122,"sourceCode":"      if ( logger.isDebugEnabled() && logBuffer != null ) {\n        logger.debug( logBuffer.getBuffer().toString() );\n      }\n      throw new KettleException( BaseMessages.getString( PKG,\n        \"RepositoryConnectionUtils.ERROR_0004_REPOSITORY_NOT_FOUND\", repositoryName ) ); //$NON-NLS-1$\n    }\n\n    if ( logger.isDebugEnabled() ) {\n      logger.debug( \" Getting repository instance \" ); //$NON-NLS-1$\n    }\n    Repository repository = null;\n    try {\n      repository =\n        PluginRegistry.getInstance().loadClass( RepositoryPluginType.class, repositoryMeta.getId(),\n          Repository.class );\n      repository.init( repositoryMeta );\n\n    } catch ( Exception e ) {\n      throw new KettleException( BaseMessages.getString(\n        \"RepositoryConnectionUtils.ERROR_0016_COULD_NOT_GET_REPOSITORY_INSTANCE\" ), e ); // $NON-NLS-1$\n    }\n\n    // OK, now try the username and password\n    if ( logger.isDebugEnabled() ) {\n      logger.debug( \"Connecting to repository \" );\n    }\n\n    // Two scenarios here: internal to server or external to server. If internal, you are already authenticated. If\n    // external, you must provide a username and additionally specify that the IP address of the machine running this\n    // code is trusted.\n    repository.connect( userName, \"ignore\" );\n\n    // OK, the repository is open and ready to use.\n    if ( logger.isDebugEnabled() ) {\n      logger.debug( \" Connected to repository \" );\n    }\n","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/repository/RepositoryConnectionUtils.java#L104-L140","documentation":"connectToRepository instantiates the repository implementation via PluginRegistry.loadClass(RepositoryPluginType, repositoryMeta.getId(), Repository.class) and calls repository.init(repositoryMeta). Any failure — plugin missing, class loading error, or init exception — becomes a KettleException with ERROR_0016_COULD_NOT_GET_REPOSITORY_INSTANCE.","triggerScenarios":"repositoryMeta.getId() references a repository plugin type not registered/installed (e.g. KettleDatabaseRepository vs a custom plugin), plugin jars missing from the classpath/plugins dir, or repository.init() throwing for bad RepositoryMeta settings.","commonSituations":"Custom repository plugin removed or not deployed on the server; version mismatch where the repositories.xml references a plugin id dropped in a newer Pentaho release; incomplete plugin folder after upgrade; classloader issues in embedded/OSGi environments.","solutions":["Check the cause chain for ClassNotFoundException/PluginNotFoundException and verify the repository plugin id in repositories.xml matches an installed plugin.","Ensure the plugin jar (e.g. for database repositories it's built-in; for others the plugin directory) is present and complete.","Upgrade/downgrade so the plugin id matches your Pentaho version, and regenerate repositories.xml entries.","Test plugin resolution directly: PluginRegistry.getInstance().loadClass(RepositoryPluginType.class, id, Repository.class) to isolate the failure.","Validate RepositoryMeta contents (id, connection settings) before init, since init() failures also land here."],"exampleFix":"// before: failing because custom plugin id missing on server\nRepository rep = RepositoryConnectionUtils.connectToRepository(log, null, \"MyCustomRepo\", u, p, null, false);\n// after: verify the plugin exists first\nRepositoryMeta rm = ...;\nboolean ok = PluginRegistry.getInstance().getPlugins(RepositoryPluginType.class).stream()\n    .anyMatch(p -> p.getIds()[0].equals(rm.getId()));\nif (!ok) throw new IllegalStateException(\"Repository plugin not installed: \" + rm.getId());\nRepository rep = RepositoryConnectionUtils.connectToRepository(log, null, \"MyCustomRepo\", u, p, null, false);","handlingStrategy":"validation","validationCode":"boolean pluginInstalled = PluginRegistry.getInstance().getPlugins(RepositoryPluginType.class).stream()\n    .anyMatch(p -> p.getIds()[0].equals(repositoryMeta.getId()));\nif (!pluginInstalled) throw new IllegalStateException(\"Repository plugin not installed: \" + repositoryMeta.getId());","typeGuard":null,"tryCatchPattern":"try { rep = RepositoryConnectionUtils.connectToRepository(...); } catch (KettleException e) { if (e.getMessage().contains(\"ERROR_0016\")) { log.error(\"Repository plugin load/init failed; check plugins dir and cause\", e); } throw e; }","preventionTips":["Deploy all repository plugin jars on every environment","After PDI upgrades, regenerate repositories.xml entries for renamed plugin ids","Verify plugin presence at application startup rather than at connect time"],"tags":["plugin","classloading","repository-connection","pdi"],"backgroundTag":"module-init-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"}