{"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":"exception","errorClass":"MojoFailureException","httpStatus":null,"severity":"error","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/c31c9215e131f8c17e79f8901b48c13ee6aa8e7a/api-checker/maven-plugin/src/main/java/org/apache/kafka/maven/KafkaInternalApiCheckerMojo.java#L114-L150","documentation":"Maven mojo equivalent of the Gradle task's no-kafka-dependency error. Thrown by KafkaInternalApiCheckerMojo.handleNoKafkaDependency() as a MojoFailureException when failOnNoKafkaDependency is true and getKafkaJarsFromDependencies() returned an empty list. The mojo scans project.getArtifacts() for entries whose groupId equals 'org.apache.kafka' (line 197) to build the API surface; with none present, the scan would be meaningless.","triggerScenarios":"execute() line 113-116: kafkaJars.isEmpty() is true, handleNoKafkaDependency() runs, and failOnNoKafkaDependency is true. Produced when the Maven project has no org.apache.kafka:* dependency on its compile+runtime classpath (ResolutionScope.COMPILE_PLUS_RUNTIME) and the strict flag is enabled in pom.xml or via -Dkafka.internal-api-checker.failOnNoKafkaDependency=true.","commonSituations":"A Kafka-using module whose dependency was removed or scope-changed to test-only; pom using a shaded/relocated Kafka artifact whose groupId is no longer org.apache.kafka; a new module where the dependency was never declared; a profile that strips the Kafka dependency in some environments; running mvn verify on a module that does not actually depend on Kafka but inherited the plugin via parent pom.","solutions":["Add the Kafka dependency to the module: <dependency><groupId>org.apache.kafka</groupId><artifactId>kafka-clients</artifactId><version>3.8.0</version></dependency>.","If the Kafka dependency is shaded or relocated, manually configure the jars via the classesDirectories parameter or fork the plugin to extend the groupId filter.","If the module legitimately has no Kafka surface, disable the mojo for it: -Dkafka.internal-api-checker.enabled=false, or set <failOnNoKafkaDependency>false</failOnNoKafkaDependency> to fall back to warn-and-skip.","If the plugin was inherited from a parent pom but only applies to some modules, move it into a profile or attach <execution> only to the Kafka-consuming modules."],"exampleFix":"<!-- before -->\n<plugin>\n  <groupId>org.apache.kafka</groupId>\n  <artifactId>kafka-internal-api-checker-maven-plugin</artifactId>\n  <configuration><failOnNoKafkaDependency>true</failOnNoKafkaDependency></configuration>\n</plugin>\n<!-- (no org.apache.kafka dependency in this module) -->\n\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: ensure an org.apache.kafka artifact is a compile/runtime dependency -->\n<dependency>\n  <groupId>org.apache.kafka</groupId>\n  <artifactId>kafka-clients</artifactId>\n  <version>${kafka.version}</version>\n</dependency>\n# pre-check before invoking the mojo:\n# mvn -q dependency:list | grep org.apache.kafka || echo 'NO KAFKA DEPENDENCY'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare at least one org.apache.kafka:* dependency in the module running the mojo; the checker scans project.getArtifacts() for that groupId.","Set <failOnNoKafkaDependency>true</failOnNoKafkaDependency> in CI builds so a missing dependency fails rather than silently reporting 0 violations.","After dependency changes, run mvn dependency:tree and confirm the kafka artifact appears under compile/runtime scope."],"tags":["maven","kafka","api-checker","classpath","configuration"],"analyzedSha":"c31c9215e131f8c17e79f8901b48c13ee6aa8e7a","analyzedAt":"2026-08-03T12:34:05.770Z","schemaVersion":2}