{"record":{"id":"101ba133205f22f9","repo":"apache/kafka","slug":"no-org-apache-kafka-dependencies-found-on-the-pr","errorCode":null,"errorMessage":"No org.apache.kafka:* dependencies found on the project classpath. The checker cannot derive an API surface and would produce a meaningless '0 violations' report — likely a classpath or configuration issue.","messagePattern":"No org\\.apache\\.kafka:\\* dependencies found on the project classpath\\. The checker cannot derive an API surface and would produce a meaningless '0 violations' report — likely a classpath or configuration issue\\.","errorType":"validation","errorClass":"MojoFailureException","httpStatus":null,"severity":"warning","filePath":"api-checker/maven-plugin/src/main/java/org/apache/kafka/maven/KafkaInternalApiCheckerMojo.java","lineNumber":132,"sourceCode":"            handleNoKafkaDependency();\n            return;\n        }\n\n        List<File> classRoots = PublicApiChecker.collectExistingRoots(classesDirectories);\n        if (classRoots.isEmpty()) {\n            getLog().info(\"No class files found, skipping internal API check\");\n            return;\n        }\n\n        runCheck(kafkaJars, classRoots);\n    }\n\n    private void handleNoKafkaDependency() throws MojoFailureException {\n        String msg = \"No org.apache.kafka:* dependencies found on the project classpath. \"\n                + \"The checker cannot derive an API surface and would produce a meaningless \"\n                + \"'0 violations' report — likely a classpath or configuration issue.\";\n        if (failOnNoKafkaDependency) {\n            throw new MojoFailureException(msg);\n        }\n        getLog().warn(msg + \" Skipping internal API check. \"\n                + \"Set <failOnNoKafkaDependency>true</failOnNoKafkaDependency> to make this fatal.\");\n    }\n\n    private void runCheck(List<File> kafkaJars, List<File> classRoots)\n            throws MojoExecutionException, MojoFailureException {\n        try {\n            getLog().info(\"Scanning \" + classRoots.size() + \" class file root(s) for internal API usage\");\n            CheckResult result = new PublicApiChecker(kafkaJars).checkBytecode(classRoots);\n            reportResults(result);\n        } catch (IOException e) {\n            throw new MojoExecutionException(\"Failed to check internal API usage: \" + e.getMessage(), e);\n        }\n    }\n\n    private void reportResults(CheckResult result) throws MojoFailureException, IOException {\n        List<PublicApiViolation> violations = result.violations();","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/apache/kafka/blob/996fb4585aa1bcc8980b0e1b8d6b168b986cd979/api-checker/maven-plugin/src/main/java/org/apache/kafka/maven/KafkaInternalApiCheckerMojo.java#L114-L150","documentation":"MojoFailureException thrown by the Maven KafkaInternalApiCheckerMojo when no org.apache.kafka:* artifacts are on the project classpath and failOnNoKafkaDependency is true. The Maven analogue of the Gradle task's error 0: the checker cannot derive the API surface without kafka jars, so a '0 violations' result would be meaningless. When failOnNoKafkaDependency is false (default) it logs a warning and skips.","triggerScenarios":"handleNoKafkaDependency() at line 132 throws when the resolved kafkaJars list is empty and the failOnNoKafkaDependency parameter is true. The list is empty when the Maven project has no org.apache.kafka dependency in compile/runtime scope.","commonSituations":"Running the goal on a module that does not depend on kafka-clients; declaring the dependency as provided/optional in a scope the checker does not scan; typo in groupId (e.g. kafka instead of org.apache.kafka); testing the plugin in a fresh project.","solutions":["Add a kafka dependency: <dependency><groupId>org.apache.kafka</groupId><artifactId>kafka-clients</artifactId><version>...</version></dependency>.","Set <failOnNoKafkaDependency>false</failOnNoKafkaDependency> in the mojo config if the absence is expected, to downgrade to a warning.","Confirm scope — use compile or runtime scope, not test-only, if you want it scanned.","Run mvn dependency:tree | grep org.apache.kafka to verify resolution."],"exampleFix":"<!-- before: no kafka dependency, failOnNoKafkaDependency=true -->\n<configuration><failOnNoKafkaDependency>true</failOnNoKafkaDependency></configuration>\n<!-- after -->\n<dependencies>\n  <dependency>\n    <groupId>org.apache.kafka</groupId>\n    <artifactId>kafka-clients</artifactId>\n    <version>3.8.0</version>\n  </dependency>\n</dependencies>","handlingStrategy":"validation","validationCode":"<!-- pom.xml: declare a kafka dependency OR set failOnNoKafkaDependency=false -->\n<dependencies>\n  <dependency>\n    <groupId>org.apache.kafka</groupId>\n    <artifactId>kafka-clients</artifactId>\n    <version>${kafka.version}</version>\n  </dependency>\n</dependencies>","typeGuard":null,"tryCatchPattern":"try { kafkaInternalApiChecker.execute(); } catch (MojoFailureException e) { if (e.message.contains('No org.apache.kafka')) { getLog().warn('Skipping: no kafka dependency'); } else throw e; }","preventionTips":["Add the kafka-clients (or relevant) dependency in compile/runtime scope.","Set failOnNoKafkaDependency=false for modules that legitimately have none.","Run mvn dependency:tree to confirm org.apache.kafka resolves."],"tags":["maven","api-checker","configuration","build"],"backgroundTag":null,"analyzedSha":"996fb4585aa1bcc8980b0e1b8d6b168b986cd979","analyzedAt":"2026-08-11T22:03:28.655Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}