apache/maven · warning

Unknown reference type for

Error message

Unknown reference type for {}: {}, using default

What it means

Maven 4 interns model objects (Dependency, Plugin, ...) in DefaultModelObjectPool to cut memory use. The reference strength of a pooled class can be tuned per simple class name via the system property 'maven.model.processor.referenceType.<ClassName>'. The value must match a Cache.ReferenceType constant (NONE, SOFT, WEAK, HARD, case-insensitive); valueOf() throws IllegalArgumentException for anything else and this warn is emitted, falling back to the default reference type.

Solutions

  1. Set the property to one of the exact enum names NONE, SOFT, WEAK or HARD (any case): -Dmaven.model.processor.referenceType.Dependency=SOFT
  2. Remove surrounding whitespace/quotes from the value in MAVEN_OPTS, .mvn/jvm.config or the CI variable
  3. Delete the per-type property entirely and rely on the global 'maven.model.processor.referenceType' if per-class tuning was not intended

Example fix

# before
export MAVEN_OPTS="$MAVEN_OPTS -Dmaven.model.processor.referenceType.Dependency=softish"

# after
export MAVEN_OPTS="$MAVEN_OPTS -Dmaven.model.processor.referenceType.Dependency=SOFT"
Defensive patterns

Strategy: validation

Validate before calling

// before launching Maven / setting the system property
static final Set<String> VALID_REF_TYPES = Set.of("NONE", "SOFT", "WEAK", "HARD");

static boolean isValidRefType(String value) {
    return value != null && VALID_REF_TYPES.contains(value.strip().toUpperCase(Locale.ROOT));
}

// guard
String v = System.getProperty("maven.model.processor.referenceType.Dependency");
if (v != null && !isValidRefType(v)) {
    throw new IllegalArgumentException("Fix maven.model.processor.referenceType.Dependency: " + v);
}

Prevention

When it happens

Trigger: Starting Maven (or an embedded Maven instance) with -Dmaven.model.processor.referenceType.Dependency=<bad>, where <bad> is not NONE/SOFT/WEAK/HARD (e.g. 'softish', 'STRONG', or a value with leading/trailing whitespace, since it is never trimmed). getReferenceTypeForClass() is consulted on every internObject() call for that class, so the warn repeats.

Common situations: Typos in MAVEN_OPTS or CI environment variables; copy-pasting tuning advice written for a different library; values quoted with stray spaces (' SOFT '); expecting PascalCase names that do not exist (e.g. 'WEAK_REFERENCE').

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelObjectPool.java:132

        return Cache.newCache(referenceType);
    }

    /**
     * Gets the reference type to use for a specific object type.
     * Checks for per-type configuration first, then falls back to default.
     */
    private Cache.ReferenceType getReferenceTypeForClass(Class<?> objectType) {
        String className = objectType.getSimpleName();

        // Check for per-type configuration first
        String perTypeProperty = Constants.MAVEN_MODEL_PROCESSOR_REFERENCE_TYPE_PREFIX + className;
        String perTypeValue = getProperty(perTypeProperty, null);

        if (perTypeValue != null) {
            try {
                return Cache.ReferenceType.valueOf(perTypeValue.toUpperCase());
            } catch (IllegalArgumentException e) {
                LOGGER.warn("Unknown reference type for " + className + ": " + perTypeValue + ", using default");
            }
        }

        // Fall back to default reference type
        return getDefaultReferenceType();
    }

    /**
     * Gets the default reference type from system properties.
     */
    private Cache.ReferenceType getDefaultReferenceType() {
        try {
            String referenceTypeProperty =
                    getProperty(Constants.MAVEN_MODEL_PROCESSOR_REFERENCE_TYPE, Cache.ReferenceType.HARD.name());
            return Cache.ReferenceType.valueOf(referenceTypeProperty.toUpperCase());
        } catch (IllegalArgumentException e) {
            LOGGER.warn("Unknown default reference type, using HARD");
            return Cache.ReferenceType.HARD;

View on GitHub (pinned to e4093d4e12)