{"record":{"id":"aad38e8a8bc981e9","repo":"pentaho/pentaho-kettle","slug":"unable-to-get-the-constructor-for-repositoryroleclass","errorCode":null,"errorMessage":"Unable to get the constructor for ${repositoryRoleClass}","messagePattern":"Unable to get the constructor for (.+?)","errorType":"exception","errorClass":"UIObjectCreationException","httpStatus":null,"severity":"error","filePath":"plugins/pur/core/src/main/java/org/pentaho/di/ui/repository/pur/repositoryexplorer/UIEEObjectRegistery.java","lineNumber":60,"sourceCode":"\n  public void registerUIRepositoryRoleClass( Class<?> repositoryRoleClass ) {\n    this.repositoryRoleClass = repositoryRoleClass;\n  }\n\n  public Class<?> getRegisteredUIRepositoryRoleClass() {\n    return this.repositoryRoleClass;\n  }\n\n  public IUIRole constructUIRepositoryRole( IRole role ) throws UIObjectCreationException {\n    try {\n      if ( repositoryRoleClass == null ) {\n        repositoryRoleClass = DEFAULT_UIREPOSITORYROLE_CLASS;\n      }\n      Constructor<?> constructor = repositoryRoleClass.getConstructor( IRole.class );\n      if ( constructor != null ) {\n        return (IUIRole) constructor.newInstance( role );\n      } else {\n        throw new UIObjectCreationException( \"Unable to get the constructor for \" + repositoryRoleClass );\n      }\n    } catch ( Exception e ) {\n      throw new UIObjectCreationException( \"Unable to instantiate object for \" + repositoryRoleClass );\n    }\n  }\n}\n","sourceCodeStart":42,"sourceCodeEnd":67,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/pur/core/src/main/java/org/pentaho/di/ui/repository/pur/repositoryexplorer/UIEEObjectRegistery.java#L42-L67","documentation":"UIEEObjectRegistery.constructUIRepositoryRole uses reflection to build an IUIRole from an IRole via a constructor taking IRole. Class.getConstructor(IRole.class) throws NoSuchMethodException (never returns null), so the null check is dead code; the message indicates the registered UI role class has no public IRole constructor.","triggerScenarios":"The class registered via setClass (or DEFAULT_UIREPOSITORYROLE_CLASS) lacks a public constructor accepting IRole, so getConstructor throws NoSuchMethodException before the null check can succeed.","commonSituations":"Registering a custom UIRepositoryRole subclass that only defines a no-arg or different-arg constructor; class hierarchy changes in Pentaho (PDI) EE plugin upgrades where the IRole constructor signature changed; misconfigured custom role class in the registry.","solutions":["Ensure the registered UI role class declares a public constructor accepting IRole (public UIRepositoryRole(IRole role) {...})","Verify DEFAULT_UIREPOSITORYROLE_CLASS / setClass points to UIRepositoryRole (or a valid subclass) and was not changed or left null unexpectedly","Check for plugins or patches that replaced the role class; restore the default class","Note: after getConstructor fails, the generic catch throws 'Unable to instantiate object for ...' — inspect that exception's cause for NoSuchMethodException"],"exampleFix":"// before\npublic class MyUIRole implements IUIRole {\n  public MyUIRole() { }\n}\n// after\npublic class MyUIRole implements IUIRole {\n  public MyUIRole(IRole role) { /* init from role */ }\n}","handlingStrategy":"try-catch","validationCode":"Class<?> cls = registryClass;\nboolean ok = java.lang.reflect.Modifier.isPublic(cls.getModifiers())\n  && !cls.isInterface()\n  && !java.lang.reflect.Modifier.isAbstract(cls.getModifiers())\n  && java.util.Arrays.stream(cls.getConstructors()).anyMatch(c -> c.getParameterCount() == 1 && c.getParameterTypes()[0] == IRole.class);\n","typeGuard":"static boolean hasRoleConstructor(Class<?> cls) {\n  try { cls.getConstructor(IRole.class); return true; } catch (NoSuchMethodException e) { return false; }\n}\n","tryCatchPattern":"try {\n  IUIRole uiRole = registry.constructUIRepositoryRole(role);\n} catch (UIObjectCreationException e) {\n  log.error(\"Failed to create UI role for \" + role, e);\n  // fall back to default UIRepositoryRole\n}\n","preventionTips":["Always give custom IUIRole classes a public constructor accepting IRole","Keep registered classes concrete (not abstract/interfaces)","Log exception causes when wrapping reflection failures"],"tags":["reflection","constructor","pentaho","kettle"],"backgroundTag":"invalid-constructor-argument","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"}