apache/maven · warning · OverConstrainedVersionException

The artifact has no valid ranges

Error message

The artifact has no valid ranges

What it means

Building the effective settings (user plus global settings.xml plus project configuration) returned SettingsProblem entries. This header is printed, each problem follows as 'message @ location', and the build continues with the merged settings. Later oddities such as missing mirrors, servers, or profiles often trace back to these skipped pieces.

Source

Thrown at compat/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java:402

                // move on to next in r2
                if (i2.hasNext()) {
                    res2 = i2.next();
                } else {
                    done = true;
                }
            }
        }

        return restrictions;
    }

    public ArtifactVersion getSelectedVersion(Artifact artifact) throws OverConstrainedVersionException {
        ArtifactVersion version;
        if (recommendedVersion != null) {
            version = recommendedVersion;
        } else {
            if (restrictions.isEmpty()) {
                throw new OverConstrainedVersionException("The artifact has no valid ranges", artifact);
            }

            version = null;
        }
        return version;
    }

    public boolean isSelectedVersionKnown(Artifact artifact) throws OverConstrainedVersionException {
        boolean value = false;
        if (recommendedVersion != null) {
            value = true;
        } else {
            if (restrictions.isEmpty()) {
                throw new OverConstrainedVersionException("The artifact has no valid ranges", artifact);
            }
        }
        return value;
    }

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Read each 'message @ location' line and fix the named element in that settings.xml
  2. Check the file parses: xmllint --noout ~/.m2/settings.xml
  3. Compare against the settings reference: element order and nesting matter
  4. Re-run mvn and verify the warning block no longer appears

Example fix

<!-- before: duplicate mirror id 'corp' -->
<mirrors>
  <mirror><id>corp</id><url>https://nws1.example.com/repo</url><mirrorOf>central</mirrorOf></mirror>
  <mirror><id>corp</id><url>https://nws2.example.com/repo</url><mirrorOf>*</mirrorOf></mirror>
</mirrors>
<!-- after: unique ids -->
<mirrors>
  <mirror><id>corp-central</id><url>https://nws1.example.com/repo</url><mirrorOf>central</mirrorOf></mirror>
  <mirror><id>corp-all</id><url>https://nws2.example.com/repo</url><mirrorOf>*</mirrorOf></mirror>
</mirrors>
Defensive patterns

Strategy: validation

Validate before calling

xmllint --noout ~/.m2/settings.xml 2>&1
xmllint --noout /etc/maven/settings.xml 2>&1 || true   # global settings, if present

Prevention

When it happens

Trigger: A settings.xml with malformed XML, unknown or misplaced elements, duplicate mirror or server ids, or invalid values such as a non-boolean offline flag.

Common situations: Hand-edited settings.xml after onboarding new repositories; IDE-injected settings layers; CI copying templates that drift from the schema.

Related errors


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