apache/kafka · warning · MojoFailureException

No org.apache.kafka:* dependencies found on the project…

Error message

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.

What it means

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.

Solutions

  1. Add a kafka dependency: <dependency><groupId>org.apache.kafka</groupId><artifactId>kafka-clients</artifactId><version>...</version></dependency>.
  2. Set <failOnNoKafkaDependency>false</failOnNoKafkaDependency> in the mojo config if the absence is expected, to downgrade to a warning.
  3. Confirm scope — use compile or runtime scope, not test-only, if you want it scanned.
  4. Run mvn dependency:tree | grep org.apache.kafka to verify resolution.

Example fix

<!-- before: no kafka dependency, failOnNoKafkaDependency=true -->
<configuration><failOnNoKafkaDependency>true</failOnNoKafkaDependency></configuration>
<!-- after -->
<dependencies>
  <dependency>
    <groupId>org.apache.kafka</groupId>
    <artifactId>kafka-clients</artifactId>
    <version>3.8.0</version>
  </dependency>
</dependencies>
Defensive patterns

Strategy: validation

Validate before calling

<!-- pom.xml: declare a kafka dependency OR set failOnNoKafkaDependency=false -->
<dependencies>
  <dependency>
    <groupId>org.apache.kafka</groupId>
    <artifactId>kafka-clients</artifactId>
    <version>${kafka.version}</version>
  </dependency>
</dependencies>

Try / catch

try { kafkaInternalApiChecker.execute(); } catch (MojoFailureException e) { if (e.message.contains('No org.apache.kafka')) { getLog().warn('Skipping: no kafka dependency'); } else throw e; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of apache/kafka@996fb4585a (2026-08-11). Data as JSON: /api/errors/101ba133205f22f9. Report an issue: GitHub.

Appendix: source

Thrown at api-checker/maven-plugin/src/main/java/org/apache/kafka/maven/KafkaInternalApiCheckerMojo.java:132

            handleNoKafkaDependency();
            return;
        }

        List<File> classRoots = PublicApiChecker.collectExistingRoots(classesDirectories);
        if (classRoots.isEmpty()) {
            getLog().info("No class files found, skipping internal API check");
            return;
        }

        runCheck(kafkaJars, classRoots);
    }

    private void handleNoKafkaDependency() throws MojoFailureException {
        String msg = "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.";
        if (failOnNoKafkaDependency) {
            throw new MojoFailureException(msg);
        }
        getLog().warn(msg + " Skipping internal API check. "
                + "Set <failOnNoKafkaDependency>true</failOnNoKafkaDependency> to make this fatal.");
    }

    private void runCheck(List<File> kafkaJars, List<File> classRoots)
            throws MojoExecutionException, MojoFailureException {
        try {
            getLog().info("Scanning " + classRoots.size() + " class file root(s) for internal API usage");
            CheckResult result = new PublicApiChecker(kafkaJars).checkBytecode(classRoots);
            reportResults(result);
        } catch (IOException e) {
            throw new MojoExecutionException("Failed to check internal API usage: " + e.getMessage(), e);
        }
    }

    private void reportResults(CheckResult result) throws MojoFailureException, IOException {
        List<PublicApiViolation> violations = result.violations();

View on GitHub (pinned to 996fb4585a)