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
- Find the call site passing null into the BeanManager method and ensure the type/qualifier argument is non-null before the call.
- If the value comes from configuration or optional injection, initialize it with a sensible default or reject it early at startup.
- 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
- Apply Objects.requireNonNull to type/qualifier inputs at API boundaries before touching BeanManager.
- Never forward optional/config-derived values unguarded into CDI lookup calls.
- Write unit tests for lookup helpers using null inputs.
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
- Unsupported injection point target: <injectionPoint>
- Method ${method} of class ${beanClass} is not a producer met
- Injected field cannot be annotated with @Produces: ${field}
- Field ${field} of class ${beanClass} is not a producer field
- Non-static public field ${field} present on normal scoped be
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/1ffaa68c71f235fe.
Report an issue: GitHub.