quarkusio/quarkus · error · IllegalStateException

Failed to determine version for project model

Error message

Failed to determine version for project model

What it means

ModelUtils.getRawVersion(Model) returns the model's version, falling back to the parent's version; if neither is present it throws IllegalStateException. The bootstrap needs concrete coordinates for the project, and a POM without any version (own or inherited in the raw model) cannot be identified.

Source

Thrown at independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/ModelUtils.java:157

                return groupId;
            }
        }
        throw new IllegalStateException("Failed to determine groupId for project model");
    }

    /**
     * Returns the raw version of the model. This method returns the result of {@link #getRawVersionOrNull(Model)}
     * except if it's null, it throws an exception.
     *
     * @param model POM
     * @return raw model
     */
    public static String getRawVersion(Model model) {
        String version = getRawVersionOrNull(model);
        if (version != null) {
            return version;
        }
        throw new IllegalStateException("Failed to determine version for project model");
    }

    /**
     * Returns the raw version of the model. If the model does not include
     * the version directly and the coordinates of the parent artifact are configured,
     * the parent version will be returned.
     * If the parent coordinates are not configured, the method will return null.
     * The version is raw in a sense if it's a property expression, the
     * expression will not be resolved.
     *
     * @param model POM
     * @return raw model
     */
    public static String getRawVersionOrNull(Model model) {
        String version = model.getVersion();
        if (version != null) {
            return version;
        }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Add <version> to the pom.xml project element (or ensure the <parent> block carries a version).
  2. When building a Model in code, call model.setVersion(...) before handing it to the resolver.
  3. Check ModelUtils.getRawVersionOrNull(model) != null before calling getRawVersion and handle the null case explicitly.

Example fix

// before
Model model = new Model();
model.setGroupId("com.example");
String v = ModelUtils.getRawVersion(model); // IllegalStateException
// after
model.setVersion("1.0.0");
String v = ModelUtils.getRawVersion(model);
Defensive patterns

Strategy: validation

Validate before calling

if (ModelUtils.getRawVersionOrNull(model) == null) {
    throw new IllegalArgumentException("POM has no version (own or parent): " + model.getPomFile());
}
String version = ModelUtils.getRawVersion(model);

Type guard

static boolean hasVersion(Model model) {
    return model.getVersion() != null
        || (model.getParent() != null && model.getParent().getVersion() != null);
}

Try / catch

try {
    String v = ModelUtils.getRawVersion(model);
} catch (IllegalStateException e) {
    // model has neither version nor parent version — repair the pom
}

Prevention

When it happens

Trigger: Calling ModelUtils.getRawVersion/getVersion on a raw Model that has no <version> in the project element and no <parent> with <version> — e.g. a programmatically built Model, a minimal pom.xml missing the version, or the MISSING_MODEL placeholder.

Common situations: Generated POMs missing the version element; CI-friendly setups where the version was moved to properties but the element itself removed entirely; constructing Model objects in code and forgetting setVersion(); reading a POM whose parent block omits version (invalid for Maven too).

Related errors


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