{"record":{"id":"b14d5914e9eca24a","repo":"pentaho/pentaho-kettle","slug":"unable-to-instantiate-object-for","errorCode":null,"errorMessage":"Unable to instantiate object for ","messagePattern":"Unable to instantiate object for ","errorType":"exception","errorClass":"UIObjectCreationException","httpStatus":null,"severity":"error","filePath":"ui/src/main/java/org/pentaho/di/ui/repository/repositoryexplorer/model/UIObjectRegistry.java","lineNumber":115,"sourceCode":"        throw new UIObjectCreationException( \"Unable to get the constructor for \" + repositoryUserClass );\n      }\n    } catch ( Exception e ) {\n      throw new UIObjectCreationException( \"Unable to instantiate object for \" + repositoryUserClass );\n    }\n  }\n\n  public UIJob constructUIJob( RepositoryElementMetaInterface rc, UIRepositoryDirectory parent, Repository rep ) throws UIObjectCreationException {\n    try {\n      Constructor<?> constructor =\n        jobClass.getConstructor(\n          RepositoryElementMetaInterface.class, UIRepositoryDirectory.class, Repository.class );\n      if ( constructor != null ) {\n        return (UIJob) constructor.newInstance( rc, parent, rep );\n      } else {\n        throw new UIObjectCreationException( \"Unable to get the constructor for \" + jobClass );\n      }\n    } catch ( Exception e ) {\n      throw new UIObjectCreationException( \"Unable to instantiate object for \" + jobClass );\n    }\n  }\n\n  public UITransformation constructUITransformation( RepositoryElementMetaInterface rc,\n    UIRepositoryDirectory parent, Repository rep ) throws UIObjectCreationException {\n    try {\n      Constructor<?> constructor =\n        transClass.getConstructor(\n          RepositoryElementMetaInterface.class, UIRepositoryDirectory.class, Repository.class );\n      if ( constructor != null ) {\n        return (UITransformation) constructor.newInstance( rc, parent, rep );\n      } else {\n        throw new UIObjectCreationException( \"Unable to get the constructor for \" + transClass );\n      }\n    } catch ( Exception e ) {\n      throw new UIObjectCreationException( \"Unable to instantiate object for \" + transClass );\n    }\n  }","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/ui/src/main/java/org/pentaho/di/ui/repository/repositoryexplorer/model/UIObjectRegistry.java#L97-L133","documentation":"UIObjectRegistry.constructUIJob() reflectively instantiates the registered UIJob class. If newInstance() fails for any reason (constructor throws, instantiation error, illegal access), it throws UIObjectCreationException 'Unable to instantiate object for ' + jobClass. Note the original exception is swallowed, hiding the real cause.","triggerScenarios":"The registered UIJob subclass lacks a (RepositoryElementMetaInterface, UIRepositoryDirectory, Repository) constructor, its constructor throws, or the class cannot be instantiated under the current classloader.","commonSituations":"Custom UIObjectRegistry configuration registering a job class with a mismatched constructor signature; classloader issues in plugin/SWT environments; upgraded PDI version changed the expected constructor; the constructor throws NPE because Repository is null.","solutions":["Ensure the registered UIJob class has a public constructor matching (RepositoryElementMetaInterface, UIRepositoryDirectory, Repository)","Log or inspect the caught Exception e — temporarily add e as the exception cause to find the root failure","Revert custom registry registrations to the default UIObjectRegistry classes","Check the class is loadable by the current classloader (no plugin classloader mismatch)"],"exampleFix":"// before\nthrow new UIObjectCreationException( \"Unable to instantiate object for \" + jobClass );\n// after\nthrow new UIObjectCreationException( \"Unable to instantiate object for \" + jobClass, e );","handlingStrategy":"try-catch","validationCode":"// verify the registered class has the expected constructor\njobClass.getConstructor(RepositoryElementMetaInterface.class, UIRepositoryDirectory.class, Repository.class);","typeGuard":"boolean isInstantiableUIJob(Class<?> c) {\n  try { c.getConstructor(RepositoryElementMetaInterface.class, UIRepositoryDirectory.class, Repository.class); return !c.isInterface() && !java.lang.reflect.Modifier.isAbstract(c.getModifiers()); }\n  catch (NoSuchMethodException e) { return false; }\n}","tryCatchPattern":"try { UIJob job = registry.constructUIJob(rc, parent, rep); } catch (UIObjectCreationException e) { log.error(\"Registry misconfiguration for UIJob\", e); UIJob job = new UIJob(rc, parent, rep); // default fallback }","preventionTips":["Keep custom registry classes' constructor signatures in sync with the PDI version","Never register abstract classes or interfaces in UIObjectRegistry","Pass non-null Repository and RepositoryElementMetaInterface arguments","Preserve the reflection cause when customizing the registry"],"tags":["reflection","instantiation","kettle","swt","registry"],"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"}