{"record":{"id":"f04dfd41fac6414d","repo":"hashicorp/nomad","slug":"jar-path-or-class-must-be-specified","errorCode":null,"errorMessage":"jar_path or class must be specified","messagePattern":"jar_path or class must be specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/java/driver.go","lineNumber":447,"sourceCode":"\treturn nil\n}\n\nfunc (d *Driver) StartTask(cfg *drivers.TaskConfig) (handle *drivers.TaskHandle, network *drivers.DriverNetwork, err error) {\n\tif _, ok := d.tasks.Get(cfg.ID); ok {\n\t\treturn nil, nil, fmt.Errorf(\"task with ID %q already started\", cfg.ID)\n\t}\n\n\tvar driverConfig TaskConfig\n\tif err := cfg.DecodeDriverConfig(&driverConfig); err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to decode driver config: %v\", err)\n\t}\n\n\tif err := driverConfig.validate(); err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed driver config validation: %v\", err)\n\t}\n\n\tif driverConfig.Class == \"\" && driverConfig.JarPath == \"\" {\n\t\treturn nil, nil, fmt.Errorf(\"jar_path or class must be specified\")\n\t}\n\n\tabsPath, err := GetAbsolutePath(\"java\")\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to find java binary: %s\", err)\n\t}\n\n\targs := javaCmdArgs(driverConfig)\n\n\td.logger.Info(\"starting java task\", \"driver_cfg\", hclog.Fmt(\"%+v\", driverConfig), \"args\", args)\n\n\thandle = drivers.NewTaskHandle(taskHandleVersion)\n\thandle.Config = cfg\n\n\tpluginLogFile := filepath.Join(cfg.TaskDir().Dir, \"executor.out\")\n\texecutorConfig := &executor.ExecutorConfig{\n\t\tLogFile:     pluginLogFile,\n\t\tLogLevel:    \"debug\",","sourceCodeStart":429,"sourceCodeEnd":465,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/java/driver.go#L429-L465","documentation":"The Nomad java driver refuses to start a task when neither a jar_path nor a class is given in the driver task config. After decoding and validating the driver config, StartTask requires at least one of these fields so it knows what Java entry point to run (java -jar <jar> vs java <class>). It throws immediately, before attempting to locate the java binary.","triggerScenarios":"Calling StartTask (or submitting a Nomad job using driver 'java') where the task's driver config omits both 'jar_path' and 'class' — e.g. an empty/blank task block with only driver_args, jvm_options, or resource settings.","commonSituations":"Job files where the java stanza was deleted or renamed; templating that rendered the class/jar_path field empty; copying a task config from another driver (e.g. exec) that doesn't use these fields; typo'd field names so HCL decodes to zero values.","solutions":["Set 'class' (fully qualified main class, e.g. 'com.example.Main') or 'jar_path' (path inside the task dir) in the java driver task config.","If using artifact blocks, verify the downloaded jar name matches jar_path and that templates rendered non-empty values.","Run 'nomad job inspect' to confirm the driver config the client actually received contains jar_path or class."],"exampleFix":"// before\n  driver = \"java\"\n  config {\n    jvm_options = [\"-Xmx256m\"]\n  }\n// after\n  driver = \"java\"\n  config {\n    jar_path    = \"local/myapp.jar\"\n    jvm_options = [\"-Xmx256m\"]\n  }","handlingStrategy":"validation","validationCode":"// validate the java driver task config before submitting/starting\nfunc validateJavaCfg(cfg map[string]interface{}) error {\n    cls, _ := cfg[\"class\"].(string)\n    jar, _ := cfg[\"jar_path\"].(string)\n    if strings.TrimSpace(cls) == \"\" && strings.TrimSpace(jar) == \"\" {\n        return errors.New(\"java driver task requires either jar_path or class\")\n    }\n    return nil\n}","typeGuard":"func hasEntryPoint(cfg map[string]interface{}) bool {\n    cls, okCls := cfg[\"class\"].(string)\n    jar, okJar := cfg[\"jar_path\"].(string)\n    return (okCls && strings.TrimSpace(cls) != \"\") || (okJar && strings.TrimSpace(jar) != \"\")\n}","tryCatchPattern":null,"preventionTips":["Always set jar_path or class in every java driver task stanza.","Use 'nomad job validate' before submitting jobs to catch missing entry points.","In CI, lint job templates to assert rendered configs contain jar_path or class."],"tags":["nomad","java-driver","config-validation"],"backgroundTag":"missing-required-config-field","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}