quarkusio/quarkus · error · DefinitionException

Multiple @AroundConstruct interceptor methods declared on cl

Error message

Multiple @AroundConstruct interceptor methods declared on class: 

What it means

ArC throws this DefinitionException when an interceptor class (or a single class in its hierarchy) declares more than one non-static method annotated with @AroundConstruct. The CDI specification permits at most one @AroundConstruct interceptor method per interceptor class. The failure happens during bean discovery, so the application does not compile/deploy successfully.

Source

Thrown at independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/InterceptorInfo.java:126

                if (store.hasAnnotation(method, DotNames.PRODUCES) || store.hasAnnotation(method, DotNames.DISPOSES)) {
                    // according to spec, finding @Produces or @Disposes on a method is a DefinitionException
                    throw new DefinitionException(
                            "An interceptor method cannot be marked @Produces or @Disposes - " + method + " in class: "
                                    + aClass);
                }
                if (store.hasAnnotation(method, DotNames.AROUND_INVOKE)) {
                    addInterceptorMethod(allMethods, aroundInvokes, method, InterceptionType.AROUND_INVOKE,
                            InterceptorPlacement.INTERCEPTOR_CLASS);
                    if (++aroundInvokesFound > 1) {
                        throw new DefinitionException(
                                "Multiple @AroundInvoke interceptor methods declared on class: " + aClass);
                    }
                }
                if (store.hasAnnotation(method, DotNames.AROUND_CONSTRUCT)) {
                    addInterceptorMethod(allMethods, aroundConstructs, method, InterceptionType.AROUND_CONSTRUCT,
                            InterceptorPlacement.INTERCEPTOR_CLASS);
                    if (++aroundConstructsFound > 1) {
                        throw new DefinitionException(
                                "Multiple @AroundConstruct interceptor methods declared on class: " + aClass);
                    }
                }
                if (store.hasAnnotation(method, DotNames.POST_CONSTRUCT)) {
                    addInterceptorMethod(allMethods, postConstructs, method, InterceptionType.POST_CONSTRUCT,
                            InterceptorPlacement.INTERCEPTOR_CLASS);
                    if (++postConstructsFound > 1) {
                        throw new DefinitionException(
                                "Multiple @PostConstruct interceptor methods declared on class: " + aClass);
                    }
                }
                if (store.hasAnnotation(method, DotNames.PRE_DESTROY)) {
                    addInterceptorMethod(allMethods, preDestroys, method, InterceptionType.PRE_DESTROY,
                            InterceptorPlacement.INTERCEPTOR_CLASS);
                    if (++preDestroysFound > 1) {
                        throw new DefinitionException(
                                "Multiple @PreDestroy interceptor methods declared on class: " + aClass);
                    }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Keep exactly one @AroundConstruct method per interceptor class and move the extra logic into an unannotated helper method called from it.
  2. Remove the duplicate @AroundConstruct annotation if the method is no longer needed.
  3. Split into separate interceptor classes if the constructor interception concerns should be independent.

Example fix

// before
class MyInterceptor {
    @AroundConstruct void init1(InvocationContext ctx) throws Exception { ctx.proceed(); }
    @AroundConstruct void init2(InvocationContext ctx) throws Exception { ctx.proceed(); }
}
// after
class MyInterceptor {
    @AroundConstruct void init(InvocationContext ctx) throws Exception { ctx.proceed(); }
}
Defensive patterns

Strategy: validation

Validate before calling

long n = java.util.Arrays.stream(MyInterceptor.class.getDeclaredMethods())
    .filter(m -> m.isAnnotationPresent(jakarta.interceptor.AroundConstruct.class))
    .count();
if (n > 1) throw new IllegalStateException("Only one @AroundConstruct allowed per interceptor class");

Prevention

When it happens

Trigger: Declaring two or more non-static @AroundConstruct methods in the same interceptor class. Note the per-class counter: one @AroundConstruct in a superclass plus one in the subclass is legal; two in the same class are not.

Common situations: Copy-pasting an @AroundConstruct method when extending a base interceptor; accidentally annotating both a constructor-interception wrapper and a legacy method during migration from javax to jakarta annotations.

Related errors


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