{"record":{"id":"5acb850cb76d22be","repo":"elastic/elasticsearch","slug":"unrecognized-classpath-entry","errorCode":null,"errorMessage":"unrecognized classpath entry: {}","messagePattern":"unrecognized classpath entry: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"build-tools/src/main/java/org/elasticsearch/gradle/plugin/GenerateTestBuildInfoTask.java","lineNumber":133,"sourceCode":"     *                            whose name will be unique within its {@link ClassLoader} at run time.\n     */\n    record Location(String module, String representativeClass) {}\n\n    /**\n     * Build the list of {@link Location}s for all {@link #getCodeLocations() code locations}.\n     * There are different methods for finding these depending on if the\n     * classpath entry is a jar or a directory\n     */\n    private List<Location> buildLocationList() throws IOException {\n        List<Location> locations = new ArrayList<>();\n        for (File file : getCodeLocations().get().getFiles()) {\n            if (file.exists()) {\n                if (file.getName().endsWith(JAR_DESCRIPTOR_SUFFIX)) {\n                    extractLocationsFromJar(file, locations);\n                } else if (file.isDirectory()) {\n                    extractLocationsFromDirectory(file, locations);\n                } else {\n                    throw new IllegalArgumentException(\"unrecognized classpath entry: \" + file);\n                }\n            }\n        }\n        return List.copyOf(locations);\n    }\n\n    /**\n     * find the first class and module when the class path entry is a jar\n     */\n    private void extractLocationsFromJar(File file, List<Location> locations) throws IOException {\n        try (JarFile jarFile = new JarFile(file)) {\n            var className = extractClassNameFromJar(jarFile);\n\n            if (className.isPresent()) {\n                String moduleName = extractModuleNameFromJar(file, jarFile);\n                locations.add(new Location(moduleName, className.get()));\n            }\n        }","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools/src/main/java/org/elasticsearch/gradle/plugin/GenerateTestBuildInfoTask.java#L115-L151","documentation":"Thrown by GenerateTestBuildInfoTask.buildLocationList when a classpath code-location entry that exists on disk is neither a .jar file (matching JAR_DESCRIPTOR_SUFFIX) nor a directory. The task only knows how to scan jars and directories for test location metadata, so any other file shape is rejected.","triggerScenarios":"getCodeLocations().get().getFiles() returns a File that exists, does not end in .jar, and is not a directory (e.g. a .class file, a .zip, a broken symlink resolved to a non-jar file, a flat file passed as a code location).","commonSituations":"Misconfiguring a test task's classpath to point at a loose file or a non-jar archive; a stale build cache returning a placeholder file; symlinks in the build dir resolving to odd targets.","solutions":["Inspect the offending file path printed in the message — confirm it is unexpected, then fix the configuration feeding getCodeLocations().","Ensure all code-location entries are either compiled output directories (classes dirs) or .jar artifacts.","Run with --rerun-tasks and clean to drop stale cache entries that may have produced a non-jar file.","If you must point at an archive, package it as a .jar so the JAR_DESCRIPTOR_SUFFIX branch handles it."],"exampleFix":"// before\ntestBuildInfo {\n  codeLocations.from files('build/libs/app.zip')  // not a jar, not a dir\n}\n\n// after\ntestBuildInfo {\n  codeLocations.from sourceSets.main.output, configurations.runtimeClasspath\n}","handlingStrategy":"validation","validationCode":"for (File f : codeLocationFiles) {\n    if (!f.exists()) continue;\n    if (!f.getName().endsWith(\".jar\") && !f.isDirectory()) {\n        throw new IllegalArgumentException(\"Refusing to add non-jar non-dir classpath entry: \" + f);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only wire compiled output dirs and .jar artifacts into codeLocations.","Avoid loose .class files or non-jar archives in test classpaths.","Use Gradle's sourceSets / configurations rather than hand-built file collections."],"tags":["build","test","classpath","validation"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}