{"record":{"id":"194cb55b279c5aa7","repo":"elastic/elasticsearch","slug":"missing-classesdirs-or-classpath-property","errorCode":null,"errorMessage":"Missing 'classesDirs' or 'classpath' property.","messagePattern":"Missing 'classesDirs' or 'classpath' property\\.","errorType":"validation","errorClass":"InvalidUserDataException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/packer/CacheCacheableTestFixtures.java","lineNumber":114,"sourceCode":"                            e.printStackTrace();\n                        }\n                    }\n                }\n            } catch (Exception e) {\n                throw new RuntimeException(e);\n            } finally {\n                // Close the classloader to free resources:\n                try {\n                    if (urlLoader != null) urlLoader.close();\n                } catch (IOException ioe) {\n                    // getLogger().warn(\"Cannot close classloader: \".concat(ioe.toString()));\n                }\n            }\n        }\n\n        private URLClassLoader createClassLoader(FileCollection classpath) {\n            if (classpath == null) {\n                throw new InvalidUserDataException(\"Missing 'classesDirs' or 'classpath' property.\");\n            }\n\n            final Set<File> cpElements = new LinkedHashSet<>();\n            cpElements.addAll(classpath.getFiles());\n            final URL[] urls = new URL[cpElements.size()];\n            try {\n                int i = 0;\n                for (final File cpElement : cpElements) {\n                    urls[i++] = cpElement.toURI().toURL();\n                }\n                assert i == urls.length;\n            } catch (MalformedURLException mfue) {\n                throw new InvalidUserDataException(\"Failed to build classpath URLs.\", mfue);\n            }\n\n            return URLClassLoader.newInstance(urls, ClassLoader.getSystemClassLoader());\n        }\n","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/packer/CacheCacheableTestFixtures.java#L96-L132","documentation":"Thrown by CacheCacheableTestFixtures.createClassLoader(FileCollection) when the classpath argument is null. The task needs a classpath to build a URLClassLoader for loading/processing test fixtures; a null classpath means the task was wired without its required 'classpath' (or 'classesDirs') property. It is a configuration-time guard, not a runtime IO failure.","triggerScenarios":"A build script or plugin registers a CacheCacheableTestFixtures (or equivalent) task but never calls .classpath(...) / .classesDirs(...), so the property stays null when createClassLoader runs at execution time.","commonSituations":"Copying a task registration from another project and forgetting to wire the classpath; renaming a property during a refactor without updating the registration; a custom subproject that opts into cacheable test fixtures but has no test source set to derive the classpath from.","solutions":["Find the task registration (search for the task type / the register call) and confirm classpath and classesDirs are assigned.","Set classpath from the relevant source set: fixturesTask.classpath = sourceSets.fixtures.runtimeClasspath.","If the task genuinely needs no classpath, switch to an overload that does not create a classloader, or guard createClassLoader against null callers.","After fixing, run the specific task with --rerun-tasks to confirm."],"exampleFix":"// before\n// task not given a classpath\n\n// after\ntasks.named('cacheCacheableTestFixtures', CacheCacheableTestFixtures) {\n  classpath = sourceSets.test.runtimeClasspath\n}","handlingStrategy":"validation","validationCode":"// In the task registration, assert the property is wired before execution\ntasks.named('cacheCacheableTestFixtures').configure(t -> {\n    if (((CacheCacheableTestFixtures) t).getClasspath() == null) {\n        throw new InvalidUserDataException(\"cacheCacheableTestFixtures requires 'classpath' to be set\");\n    }\n});","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat required task inputs as mandatory: always set them in the registration block.","Add a configuration-time sanity check that fails fast with a clear message.","When copying a task from another module, audit its required properties."],"tags":["gradle","build-config","classpath","test-fixtures","task-wiring"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}