{"record":{"id":"c6060323866573ff","repo":"pentaho/pentaho-kettle","slug":"error-allocating-new-job-0","errorCode":null,"errorMessage":"Error allocating new job: {0}","messagePattern":"Error allocating new job: (.+?)","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/job/Job.java","lineNumber":351,"sourceCode":"    } else {\n      return jobMeta.getName();\n    }\n  }\n\n  public static final Job createJobWithNewClassLoader() throws KettleException {\n    try {\n      // Load the class.\n      Class<?> jobClass = Const.createNewClassLoader().loadClass( Job.class.getName() );\n\n      // create the class\n      // Try to instantiate this one...\n      Job job = (Job) jobClass.getDeclaredConstructor().newInstance();\n\n      // Done!\n      return job;\n    } catch ( Exception e ) {\n      String message = BaseMessages.getString( PKG, \"Job.Log.ErrorAllocatingNewJob\", e.toString() );\n      throw new KettleException( message, e );\n    }\n  }\n\n  public String getJobname() {\n    if ( jobMeta == null ) {\n      return null;\n    }\n    return jobMeta.getName();\n  }\n\n  public void setRepository( Repository rep ) {\n    this.rep = rep;\n  }\n\n  /**\n   * Initializes the job's variable space from the appropriate source.\n   * <p>\n   * Priority order: parentJob > jobMeta > default space.","sourceCodeStart":333,"sourceCodeEnd":369,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/job/Job.java#L333-L369","documentation":"Thrown by Job.createJobWithNewClassLoader when reflective instantiation of the Job class fails. Kettle tries to construct a new Job object via the default constructor of jobClass so the job runs in an isolated classloader; any Exception during getDeclaredConstructor().newInstance() is wrapped in a KettleException with this message.","triggerScenarios":"Calling createJobWithNewClassLoader when jobClass has no accessible no-arg constructor, the constructor throws, or the class cannot be instantiated (abstract class, interface, reflective access blocked).","commonSituations":"Custom Job subclasses lacking a public no-arg constructor; running under a SecurityManager or JPMS module that blocks setAccessible; classpath changes that make the resolved class abstract or an interface.","solutions":["Give the Job subclass a public no-arg constructor","Inspect the cause (e.getCause()) to see the actual reflective instantiation failure (InstantiationException, InvocationTargetException, etc.)","Verify the class resolved by jobClass is a concrete instantiable class","Check SecurityManager/module settings if access is being denied"],"exampleFix":"// before\nclass MyJob extends Job { MyJob(JobMeta m) { ... } }\n// after\nclass MyJob extends Job { public MyJob() { ... } public MyJob(JobMeta m) { ... } }","handlingStrategy":"try-catch","validationCode":"// before calling\nif (java.lang.reflect.Modifier.isAbstract(jobClass.getModifiers()) || jobClass.isInterface()) {\n  throw new IllegalArgumentException(jobClass + \" is not instantiable\");\n}\ntry { jobClass.getDeclaredConstructor(); } catch (NoSuchMethodException e) {\n  throw new IllegalArgumentException(jobClass + \" lacks a no-arg constructor\");\n}","typeGuard":"static boolean isInstantiable(Class<?> c) {\n  return !c.isInterface() && !java.lang.reflect.Modifier.isAbstract(c.getModifiers());\n}","tryCatchPattern":"try {\n  Job job = jobEngine.createJobWithNewClassLoader();\n} catch (KettleException e) {\n  Throwable root = e;\n  while (root.getCause() != null) root = root.getCause();\n  log.error(\"Job instantiation failed: \" + root.getMessage(), root);\n}","preventionTips":["Always provide a public no-arg constructor on custom Job subclasses","Test reflective instantiation in unit tests","Avoid SecurityManager/module restrictions on the job package"],"tags":["reflection","job-execution","classloader"],"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"}