{"record":{"id":"c38593ac80cd485a","repo":"pentaho/pentaho-kettle","slug":"unable-to-instantiate-object-for-repositoryroleclass","errorCode":null,"errorMessage":"Unable to instantiate object for ${repositoryRoleClass}","messagePattern":"Unable to instantiate object 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":63,"sourceCode":"  }\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":45,"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#L45-L67","documentation":"This is the generic catch-all of constructUIRepositoryRole: any exception while looking up or invoking the IRole constructor (NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException) is rethrown as UIObjectCreationException('Unable to instantiate object for <class>').","triggerScenarios":"Calling constructUIRepositoryRole when the registered class has no matching constructor (NoSuchMethodException), is abstract/an interface (InstantiationException), its constructor is inaccessible (IllegalAccessException), or the constructor body throws (InvocationTargetException).","commonSituations":"Custom IUIRole implementations that throw during construction; abstract classes registered by mistake; classloader/plugin version mismatches in PDI EE repositories where the role class was compiled against a different IRole API.","solutions":["Inspect the cause of this exception (it swallows details) — check logs for the underlying NoSuchMethodException or InvocationTargetException","Ensure the registered class is concrete, public, and has a public constructor taking IRole","Make the constructor body defensive so it cannot throw on valid IRole inputs","Align plugin/class versions with the PDI EE repository client version"],"exampleFix":"// before\n} catch ( Exception e ) {\n  throw new UIObjectCreationException( \"Unable to instantiate object for \" + repositoryRoleClass );\n}\n// after\n} catch ( Exception e ) {\n  throw new UIObjectCreationException( \"Unable to instantiate object for \" + repositoryRoleClass, e );\n}","handlingStrategy":"try-catch","validationCode":"if (!java.lang.reflect.Modifier.isAbstract(cls.getModifiers()) && java.util.Arrays.stream(cls.getConstructors()).anyMatch(c -> c.getParameterCount() == 1 && IRole.class.isAssignableFrom(c.getParameterTypes()[0]))) { /* safe to construct */ }\n","typeGuard":"static boolean isInstantiableRole(Class<?> cls) {\n  return !cls.isInterface() && !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}\n","tryCatchPattern":"try {\n  IUIRole uiRole = registry.constructUIRepositoryRole(role);\n} catch (UIObjectCreationException e) {\n  log.error(\"Cannot instantiate \" + cls + \": check constructor accepts IRole\", e);\n}\n","preventionTips":["Validate custom classes with getConstructor(IRole.class) before registering them","Keep constructor bodies free of throwing logic for valid inputs","Pin plugin versions to match the PDI client to avoid class mismatch"],"tags":["reflection","instantiation","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"}