{"record":{"id":"39c6f42f6eff6349","repo":"pentaho/pentaho-kettle","slug":"pluginregistry004","errorCode":"PLUGINREGISTRY004","errorMessage":"Unable to instantiate class","messagePattern":"Unable to instantiate class","errorType":"error_code","errorClass":"KettlePluginException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/plugins/PluginRegistry.java","lineNumber":526,"sourceCode":"      }\n\n      try {\n        Class<? extends T> cl;\n        if ( plugin.isNativePlugin() ) {\n          cl = (Class<? extends T>) Class.forName( className );\n        } else {\n          ClassLoader ucl = getClassLoader( plugin );\n\n          // Load the class.\n          cl = (Class<? extends T>) ucl.loadClass( className );\n        }\n\n        return cl.newInstance();\n      } catch ( ClassNotFoundException e ) {\n        throw new KettlePluginException( BaseMessages.getString(\n            PKG, \"PluginRegistry.RuntimeError.ClassNotFound.PLUGINREGISTRY003\" ), e );\n      } catch ( InstantiationException e ) {\n        throw new KettlePluginException( BaseMessages.getString(\n            PKG, \"PluginRegistry.RuntimeError.UnableToInstantiateClass.PLUGINREGISTRY004\" ), e );\n      } catch ( IllegalAccessException e ) {\n        throw new KettlePluginException( BaseMessages.getString(\n            PKG, \"PluginRegistry.RuntimeError.IllegalAccessToClass.PLUGINREGISTRY005\" ), e );\n      } catch ( Throwable e ) {\n        e.printStackTrace();\n        throw new KettlePluginException( BaseMessages.getString(\n            PKG, \"PluginRegistry.RuntimeError.UnExpectedErrorLoadingClass.PLUGINREGISTRY007\" ), e );\n      }\n    }\n  }\n\n  /**\n   * Add a PluginType to be managed by the registry\n   *\n   * @param type\n   */\n  public static void addPluginType( PluginTypeInterface type ) {","sourceCodeStart":508,"sourceCodeEnd":544,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/plugins/PluginRegistry.java#L508-L544","documentation":"In loadClass, after the class is loaded, cl.newInstance() instantiates it. An InstantiationException is rethrown as KettlePluginException 'Unable to instantiate class' (PLUGINREGISTRY004). Java throws InstantiationException when the class is abstract, an interface, or has no accessible no-arg constructor.","triggerScenarios":"cl.newInstance() on the resolved plugin class throws InstantiationException — the mapped class is abstract or an interface, or lacks a public no-argument constructor, so the registry cannot create an instance.","commonSituations":"A plugin metadata entry points at the interface or abstract base class instead of the concrete implementation; the plugin class defines only parameterized constructors; Kotlin/other-language class compiled without a no-arg constructor; class is not public.","solutions":["Point the plugin metadata (annotation/plugin.xml) at the concrete class, not an interface or abstract class.","Add a public no-argument constructor to the plugin class.","Make the class public and non-abstract.","If the class needs parameters, implement the expected plugin pattern (Kettle instantiates via no-arg constructor then calls init/setDefaults)."],"exampleFix":"// before\npublic class MyStepMeta extends BaseStepMeta {\n  public MyStepMeta(String config) { ... } // no no-arg ctor\n}\n\n// after\npublic class MyStepMeta extends BaseStepMeta {\n  public MyStepMeta() { }\n  public MyStepMeta(String config) { this(); ... }\n}","handlingStrategy":"validation","validationCode":"Class<?> cl = pluginClassLoader.loadClass(fqn);\nint mods = cl.getModifiers();\nif (Modifier.isAbstract(mods) || Modifier.isInterface(mods) || !Modifier.isPublic(mods)) {\n  throw new IllegalStateException(\"Cannot instantiate: \" + fqn);\n}\ncl.getDeclaredConstructor(); // throws if no no-arg ctor","typeGuard":"static boolean isInstantiable(Class<?> c) {\n  int m = c.getModifiers();\n  try {\n    c.getDeclaredConstructor();\n  } catch (NoSuchMethodException e) { return false; }\n  return Modifier.isPublic(m) && !Modifier.isAbstract(m) && !c.isInterface();\n}","tryCatchPattern":"try {\n  return PluginRegistry.getInstance().loadClass(plugin, pluginClass);\n} catch (KettlePluginException e) {\n  if (e.getMessage().contains(\"Unable to instantiate\")) {\n    log.error(\"Check that \" + plugin + \" maps a concrete public class with a no-arg constructor\", e);\n  }\n  throw e;\n}","preventionTips":["Map concrete implementation classes, never interfaces or abstract bases.","Always provide a public no-arg constructor on plugin classes.","Write a test that instantiates every mapped plugin class reflectively.","Follow the Kettle plugin lifecycle pattern instead of custom constructors."],"tags":["kettle","plugins","reflection","instantiation"],"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"}