apache/maven · error · IllegalStateException

lifecycle bindings injector is missing

Error message

lifecycle bindings injector is missing

What it means

DefaultModelBuilder needs a LifecycleBindingsInjector component to inject default lifecycle bindings (packaging-to-goal mappings) whenever the request has processPlugins enabled. The injector is a pluggable field, not auto-created; if the builder was wired without it, model building fails fast with this IllegalStateException before injection runs.

Source

Thrown at compat/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java:524

            throws ModelBuildingException {
        // phase 2
        Model resultModel = result.getEffectiveModel();

        DefaultModelProblemCollector problems = new DefaultModelProblemCollector(result);
        problems.setSource(resultModel);
        problems.setRootModel(resultModel);

        // model path translation
        modelPathTranslator.alignToBaseDirectory(resultModel, resultModel.getProjectDirectory(), request);

        // plugin management injection
        pluginManagementInjector.injectManagement(resultModel, request, problems);

        fireEvent(resultModel, request, problems, ModelBuildingEventCatapult.BUILD_EXTENSIONS_ASSEMBLED);

        if (request.isProcessPlugins()) {
            if (lifecycleBindingsInjector == null) {
                throw new IllegalStateException("lifecycle bindings injector is missing");
            }

            // lifecycle bindings injection
            lifecycleBindingsInjector.injectLifecycleBindings(resultModel, request, problems);
        }

        // dependency management import
        importDependencyManagement(resultModel, request, problems, imports);

        // dependency management injection
        dependencyManagementInjector.injectManagement(resultModel, request, problems);

        modelNormalizer.injectDefaultValues(resultModel, request, problems);

        if (request.isProcessPlugins()) {
            // reports configuration
            reportConfigurationExpander.expandPluginConfiguration(resultModel, request, problems);

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Wire the injector: builder.setLifecycleBindingsInjector(new DefaultLifecycleBindingsInjector()) or register the component in your DI container
  2. If plugin processing is not needed (pure model reading/validation tests), call request.setProcessPlugins(false)
  3. Prefer obtaining a fully wired ModelBuilder from DefaultModelBuilderFactory instead of manual construction
  4. Audit custom wiring once against the builder's full component list after Maven upgrades

Example fix

// before: hand-wired builder without the injector, plugins processed
DefaultModelBuilder builder = new DefaultModelBuilder()
    .setModelProcessor(processor)
    .setModelValidator(validator); // no lifecycle bindings injector
request.setProcessPlugins(true);

// after: wire the missing component (or disable plugin processing in read-only tests)
DefaultModelBuilder builder = new DefaultModelBuilder()
    .setModelProcessor(processor)
    .setModelValidator(validator)
    .setLifecycleBindingsInjector(new DefaultLifecycleBindingsInjector());
// or: request.setProcessPlugins(false);
Defensive patterns

Strategy: validation

Validate before calling

// Guarantee the wiring contract before building with plugins enabled
DefaultModelBuilder builder = new DefaultModelBuilder()
        .setModelProcessor(processor)
        .setModelValidator(validator)
        .setLifecycleBindingsInjector(new DefaultLifecycleBindingsInjector());
// and in model-only tests, avoid the requirement entirely:
request.setProcessPlugins(false);

Prevention

When it happens

Trigger: Constructing DefaultModelBuilder manually without setting a LifecycleBindingsInjector, then building a ModelBuildingRequest with isProcessPlugins() == true, typical in unit tests or custom embedded wiring.

Common situations: Test code that news up DefaultModelBuilder by hand; DI containers that do not register the lifecycle bindings injector component; migrations between Maven versions where wiring assumptions changed.

Related errors


AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21). Data as JSON: /api/errors/36405b87daf0041a. Report an issue: GitHub.