quarkusio/quarkus · error · RuntimeException

Failed to load the condition class ${testClassName} for capa

Error message

Failed to load the condition class ${testClassName} for capability ${name}

What it means

Capabilities can declare conditional activation via an inline BooleanSupplier class name embedded in the capability string. CapabilityAggregationStep.provideCapabilities loads that class from the thread-context classloader; if the condition class is not on the augmentation classpath, it throws RuntimeException naming the class and capability.

Source

Thrown at core/deployment/src/main/java/io/quarkus/deployment/steps/CapabilityAggregationStep.java:71

            final String provider = contract.getExtension();
            for (String capability : contract.getProvidesCapabilities()) {
                int conditionIndex = capability.indexOf('?');
                final String name = conditionIndex < 0 ? capability : capability.substring(0, conditionIndex);
                int testClassStart;
                boolean provide = true;
                while (conditionIndex > 0 && provide) {
                    final boolean inv = conditionIndex < capability.length() - 1
                            && capability.charAt(conditionIndex + 1) == '!';
                    testClassStart = conditionIndex + (inv ? 2 : 1);
                    conditionIndex = capability.indexOf('?', testClassStart + 1);
                    final String testClassName = capability
                            .substring(testClassStart, conditionIndex > 0 ? conditionIndex : capability.length());
                    Class<? extends BooleanSupplier> testClass;
                    try {
                        testClass = Thread.currentThread().getContextClassLoader().loadClass(testClassName)
                                .asSubclass(BooleanSupplier.class);
                    } catch (ClassNotFoundException e) {
                        throw new RuntimeException(
                                "Failed to load the condition class " + testClassName + " for capability " + name, e);
                    }

                    provide = supplierFactory.get(testClass).getAsBoolean();
                }
                if (provide) {
                    producer.produce(new CapabilityBuildItem(name, provider));
                    capabilityNames.add(name);
                }
            }
        }
        configuredCapsProducer.produce(new CapabilitiesConfiguredInDescriptorsBuildItem(capabilityNames));
    }

    /**
     * Aggregates all the capability build items. Not all the capabilities are configured in the extension descriptors.
     * Many are still produced by build steps directly.
     *

View on GitHub (pinned to e1c734241f)

Solutions

  1. Add the extension/module that provides the referenced condition class back to the application dependencies
  2. Check the capability string in the failing extension's BuildStep and verify the test class name and package are correct
  3. Align all Quarkus extension versions (quarkus-bom) so capability conditions and providers match
  4. Search the codebase for the capability name to find which extension declares the condition and why it is absent

Example fix

// before (pom.xml)
<!-- io.quarkus:quarkus-jdbc-postgresql removed, condition class missing -->
// after
<dependency>
  <groupId>io.quarkus</groupId>
  <artifactId>quarkus-jdbc-postgresql</artifactId>
</dependency>
Defensive patterns

Strategy: validation

Validate before calling

static void checkCapabilityCondition(String capability) throws ClassNotFoundException {
    int lt = capability.indexOf('<');
    if (lt > 0) {
        String cls = capability.substring(lt + 1, capability.length() - 1);
        Thread.currentThread().getContextClassLoader().loadClass(cls);
    }
}

Try / catch

try {
    // augmentation
} catch (RuntimeException e) {
    if (e.getMessage() != null && e.getMessage().startsWith("Failed to load the condition class")) {
        throw new IllegalStateException("Add the extension providing the capability condition class", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: A capability string contains a '<test-class>:<condition>' style suffix (e.g. io.quarkus.capability conditional syntax) referencing a BooleanSupplier class that is not present at augmentation time; the extension providing the condition class is missing or renamed.

Common situations: Removing/downgrading an extension that provided the condition class while another extension still declares the conditional capability; typos or renamed condition classes in capability declarations; classloader/context issues in custom build tooling.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/e7fbc28f2157d4a4. Report an issue: GitHub.