quarkusio/quarkus · error · IllegalArgumentException

${name} must be set

Error message

${name} must be set

What it means

ArC (Quarkus's CDI implementation) throws this IllegalArgumentException from its null-check helper `illegalNull` in BeanManagerImpl whenever a CDI API method (e.g. those used by isMatchingBean/isMatchingEvent) is called with a null for a mandatory parameter such as a bean type, qualifier, or event object. The CDI specification requires these arguments to be non-null, so ArC fails fast rather than producing undefined behavior downstream.

Source

Thrown at independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/BeanManagerImpl.java:384

        ArcContainerImpl.instance().registeredQualifiers.verify(specifiedQualifiers);
        ArcContainerImpl.instance().registeredQualifiers.verify(observedEventQualifiers);

        Set<Annotation> eventQualifiers = new HashSet<>(specifiedQualifiers);
        if (eventQualifiers.isEmpty()) {
            eventQualifiers.add(Default.Literal.INSTANCE);
        }
        eventQualifiers.add(Any.Literal.INSTANCE);

        Set<Type> eventTypes = new HierarchyDiscovery(specifiedType).getTypeClosure();
        if (!EventTypeAssignabilityRules.instance().matches(observedEventType, eventTypes)) {
            return false;
        }
        return ArcContainerImpl.instance().registeredQualifiers.isSubset(observedEventQualifiers, eventQualifiers);
    }

    private static void illegalNull(Object obj, String name) {
        if (obj == null) {
            throw new IllegalArgumentException(name + " must be set");
        }
    }
}

View on GitHub (pinned to e1c734241f)

Solutions

  1. Find the call site passing null into the BeanManager method and ensure the type/qualifier argument is non-null before the call.
  2. If the value comes from configuration or optional injection, initialize it with a sensible default or reject it early at startup.
  3. If you only need optional lookup, guard with a null check and skip the BeanManager call instead of calling it with null.

Example fix

// before
Bean<?> bean = beanManager.resolve(beanManager.getBeans(myType, myQualifier)); // myType may be null

// after
Objects.requireNonNull(myType, "bean type must be set");
Bean<?> bean = beanManager.resolve(beanManager.getBeans(myType, myQualifier));
Defensive patterns

Strategy: validation

Validate before calling

if (beanType == null || qualifiers == null) {
    throw new IllegalStateException("beanType and qualifiers must be non-null before BeanManager lookup");
}

Type guard

static boolean isUsableLookupArg(Object o) { return o != null; }

Try / catch

try {
    beanManager.getBeans(type, qualifiers);
} catch (IllegalArgumentException e) {
    if (!e.getMessage().contains("must be set")) throw e;
    // handle null-argument case
}

Prevention

When it happens

Trigger: Calling BeanManager methods like getBeans(), getBeans(Type, Annotation...), resolve(), fireEvent(), or event-related matching helpers while passing null for the required Type, Annotation, or Event object argument.

Common situations: Refactored code where a bean class or qualifier variable became null; injecting qualifiers dynamically from config that is absent; framework glue code that forwards nullable user input straight into BeanManager lookups.

Related errors


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