quarkusio/quarkus · error · DefinitionException
Multiple @AroundInvoke interceptor methods declared on class
Error message
Multiple @AroundInvoke interceptor methods declared on class: ${beanClass} What it means
A CDI interceptor (or intercepted bean class) may declare at most one @AroundInvoke interceptor method, including methods inherited from superclasses. ArC counts matching methods while walking the class hierarchy and throws a DefinitionException when a second one is found.
Source
Thrown at independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Beans.java:784
}
static List<MethodInfo> getAroundInvokes(ClassInfo beanClass, BeanDeployment deployment) {
AnnotationStore store = deployment.getAnnotationStore();
List<MethodInfo> methods = new ArrayList<>();
List<MethodInfo> allMethods = new ArrayList<>();
ClassInfo aClass = beanClass;
while (aClass != null) {
int aroundInvokesFound = 0;
for (MethodInfo method : aClass.methods()) {
if (Modifier.isStatic(method.flags())) {
continue;
}
if (store.hasAnnotation(method, DotNames.AROUND_INVOKE)) {
InterceptorInfo.addInterceptorMethod(allMethods, methods, method, InterceptionType.AROUND_INVOKE,
InterceptorPlacement.TARGET_CLASS);
if (++aroundInvokesFound > 1) {
throw new DefinitionException(
"Multiple @AroundInvoke interceptor methods declared on class: " + aClass);
}
}
allMethods.add(method);
}
DotName superTypeName = aClass.superName();
aClass = superTypeName == null || DotNames.OBJECT.equals(superTypeName) ? null
: getClassByName(deployment.getBeanArchiveIndex(), superTypeName);
}
Collections.reverse(methods);
return methods.isEmpty() ? List.of() : List.copyOf(methods);
}
static void analyzeType(Type type, BeanDeployment beanDeployment) {
if (type.kind() == Type.Kind.PARAMETERIZED_TYPE) {
for (Type argument : type.asParameterizedType().arguments()) {
fetchType(argument, beanDeployment);
}View on GitHub (pinned to e1c734241f)
Solutions
- Remove one of the @AroundInvoke methods or drop its annotation
- Merge the logic of both methods into a single @AroundInvoke method
- Move the shared logic into a helper called by one @AroundInvoke method
Example fix
// before
class MyInterceptor {
@AroundInvoke Object a(InvocationContext ctx) {...}
@AroundInvoke Object b(InvocationContext ctx) {...}
}
// after
class MyInterceptor {
@AroundInvoke Object intercept(InvocationContext ctx) { return a(ctx); }
Object a(InvocationContext ctx) {...}
} Defensive patterns
Strategy: validation
Validate before calling
// quick architectural check before building an interceptor
class MyInterceptor {
long aroundInvokeCount = Stream.of(MyInterceptor.class.getDeclaredMethods(),
MyInterceptor.class.getMethods())
.flatMap(Stream::of).distinct()
.filter(m -> m.isAnnotationPresent(AroundInvoke.class)).count();
if (aroundInvokeCount > 1) throw new IllegalStateException("Only one @AroundInvoke allowed");
} Try / catch
try {
quarkusBuild.start();
} catch (DefinitionException e) {
if (e.getMessage().contains("Multiple @AroundInvoke interceptor methods")) {
logger.errorf("Collapse to a single @AroundInvoke: %s", e.getMessage());
}
throw e;
} Prevention
- Only one @AroundInvoke per class hierarchy
- Search superclasses for existing @AroundInvoke before adding one
- Prefer delegating to a private helper method for extra logic
When it happens
Trigger: While building interceptor methods for aClass, a second method annotated @AroundInvoke is encountered (aroundInvokesFound > 1), counting methods declared on the class and all its superclasses.
Common situations: A subclass adds its own @AroundInvoke while the superclass already has one; copy-pasting an interceptor method into a class that already defines one; merging code from two interceptor classes into one.
Related errors
- Invalid injection of Interceptor<T> bean, can only be used i
- Type of injected Interceptor<T> does not match the type of t
- An interceptor method cannot be marked @Produces or @Dispose
- Multiple @AroundInvoke interceptor methods declared on class
- Multiple @AroundConstruct interceptor methods declared on cl
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/c13573e421142ec8.
Report an issue: GitHub.