quarkusio/quarkus · error · IllegalStateException

Failed to determine groupId for project model

Error message

Failed to determine groupId for project model

What it means

ModelUtils.getGroupId(Model) returns the model's groupId, falling back to the parent's groupId. If neither the model nor its parent declares a groupId, it throws IllegalStateException. A valid Maven POM resolved to coordinates must always have an effective groupId, so this indicates a structurally incomplete raw model.

Source

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

                }
            }
            throw new IOException("Failed to located META-INF/maven/<groupId>/<artifactId>/pom.xml in " + appJar);
        }
    }

    public static String getGroupId(Model model) {
        String groupId = model.getGroupId();
        if (groupId != null) {
            return groupId;
        }
        final Parent parent = model.getParent();
        if (parent != null) {
            groupId = parent.getGroupId();
            if (groupId != null) {
                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");
    }

    /**

View on GitHub (pinned to e1c734241f)

Solutions

  1. Add <groupId> to the project element of the pom.xml (or ensure its <parent> block has a groupId).
  2. Validate the POM with `mvn help:effective-pom` or `mvn validate` before feeding it to the bootstrap.
  3. In code, check model.getGroupId() == null && model.getParent() == null before calling getGroupId and treat the model as invalid.

Example fix

<!-- before -->
<project>
  <artifactId>app</artifactId>
  <version>1.0.0</version>
</project>
<!-- after -->
<project>
  <groupId>com.example</groupId>
  <artifactId>app</artifactId>
  <version>1.0.0</version>
</project>
Defensive patterns

Strategy: validation

Validate before calling

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

Type guard

static boolean hasCoordinates(Model model) {
    return model.getGroupId() != null || model.getParent() != null;
}

Try / catch

try {
    String g = ModelUtils.getGroupId(model);
} catch (IllegalStateException e) {
    // model declares neither groupId nor parent groupId — treat as invalid pom
}

Prevention

When it happens

Trigger: Calling ModelUtils.getGroupId on a raw (non-effective) Model parsed from a pom.xml whose project element declares neither <groupId> nor a <parent> with a <groupId> (e.g. a minimal/invalid pom.xml, or a MISSING_MODEL placeholder Model created with `new Model()`).

Common situations: Parsing a hand-written or generated minimal pom.xml lacking coordinates; reading a model from WorkspaceLoader.MISSING_MODEL (module without pom.xml handled as thirdparty); tools that construct Model objects programmatically without setting groupId.

Related errors


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