quarkusio/quarkus · error · DefinitionException
@Named without value may not be used on method parameter:
Error message
@Named without value may not be used on method parameter:
What it means
The @Named qualifier without an explicit value is only meaningful on classes (derived from the EL name); on a method parameter of an initializer/producer/injector method it has no resolvable value, so ArC throws a DefinitionException.
Source
Thrown at independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/InjectionPointInfo.java:95
return fromMethod(method, beanClass, beanDeployment, null, transformer);
}
static List<InjectionPointInfo> fromMethod(MethodInfo method, ClassInfo beanClass, BeanDeployment beanDeployment,
BiPredicate<Set<AnnotationInstance>, Integer> skipPredicate, InjectionPointModifier transformer) {
List<InjectionPointInfo> injectionPoints = new ArrayList<>();
for (ListIterator<Type> iterator = method.parameterTypes().listIterator(); iterator.hasNext();) {
Type paramType = iterator.next();
int position = iterator.previousIndex();
Set<AnnotationInstance> paramAnnotations = Annotations.getParameterAnnotations(beanDeployment, method, position);
if (skipPredicate != null && skipPredicate.test(paramAnnotations, position)) {
// Skip parameter, e.g. @Disposes
continue;
}
Set<AnnotationInstance> paramQualifiers = new HashSet<>();
for (AnnotationInstance paramAnnotation : paramAnnotations) {
for (AnnotationInstance annotationInstance : beanDeployment.extractQualifiers(paramAnnotation)) {
if (isNamedWithoutValue(annotationInstance)) {
throw new DefinitionException("@Named without value may not be used on method parameter: " + method);
}
paramQualifiers.add(annotationInstance);
}
}
Type type = resolveType(paramType, beanClass, method.declaringClass(), beanDeployment);
injectionPoints.add(new InjectionPointInfo(type,
transformer.applyTransformers(type, method, method.parameters().get(position), paramQualifiers),
method, method.parameters().get(position), contains(paramAnnotations, DotNames.TRANSIENT_REFERENCE),
contains(paramAnnotations, DotNames.DELEGATE)));
}
return injectionPoints;
}
public static InjectionPointInfo fromSyntheticInjectionPoint(TypeAndQualifiers typeAndQualifiers) {
return new InjectionPointInfo(typeAndQualifiers, InjectionPointKind.CDI, null, null, false, false);
}
private final TypeAndQualifiers typeAndQualifiers;View on GitHub (pinned to e1c734241f)
Solutions
- Give @Named an explicit value: @Named("myName")
- Replace bare @Named with a proper qualifier annotation
- Remove @Named from the parameter if it is not needed
Example fix
// before
void init(@Named String name) {}
// after
void init(@Named("myName") String name) {} Defensive patterns
Strategy: validation
Validate before calling
for (Method m : MyClass.class.getDeclaredMethods()) {
for (Annotation[] pa : m.getParameterAnnotations()) {
for (Annotation a : pa) {
if (a instanceof jakarta.inject.Named n && n.value().isEmpty()) {
throw new IllegalStateException("Bare @Named on parameter: " + m);
}
}
}
} Prevention
- Always supply a value when using @Named: @Named("x")
- Prefer dedicated qualifier annotations over @Named for injection points
When it happens
Trigger: Annotating a method parameter with bare @Named (no value) where qualifiers are extracted, e.g. an initializer or producer method parameter; detected in InjectionPointInfo.fromMethod.
Common situations: Copy-pasting @Named from class-level usage onto parameters; expecting @Named on a parameter to act like @Named("x") elsewhere.
Related errors
- Qualifier annotation '${qualifierClass}' contains a member '
- Stereotype must not declare @Named with a non-empty value: $
- The qualifier ${aClass} was used repeatedly but it is not an
- Error checking value of member method ${methodName} on ${dec
- Annotation is not a registered qualifier: ${annotationType}
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/fc5271fb5d1c5eb2.
Report an issue: GitHub.