quarkusio/quarkus · error · DefinitionException
Calling injectInterceptionProxy() more than once is invalid
Error message
Calling injectInterceptionProxy() more than once is invalid
What it means
BeanConfiguratorBase.injectInterceptionProxy() registers an interception proxy for a synthetic bean and must be called at most once per configurator. A second call means the interceptionProxy field is already set, so Arc throws DefinitionException to prevent silently overwriting the interception configuration.
Source
Thrown at independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanConfiguratorBase.java:428
/**
* Declares that this synthetic bean has an injection point of type {@code InterceptionProxy<PT>},
* where {@code PT} is the {@linkplain #providerType(Type) provider type} of this bean.
* An instance of {@code PT} may be used as a parameter to {@link InterceptionProxy#create(Object)}
* in the {@linkplain BeanCreator creator} of this synthetic bean.
* <p>
* If the {@code bindingsSource} is not {@code null}, interceptor bindings on the class
* of the provider type are ignored; instead, the {@code bindingsSource} class is scanned
* for interceptor binding annotations as defined in {@link io.quarkus.arc.BindingsSource}.
* <p>
* This method may only be called once. Subsequent calls throw an exception.
*
* @param bindingsSource the bindings source class, may be {@code null}
* @return self
*/
public THIS injectInterceptionProxy(DotName bindingsSource) {
if (interceptionProxy != null) {
throw new DefinitionException("Calling injectInterceptionProxy() more than once is invalid");
}
interceptionProxy = new InterceptionProxyInfo(bindingsSource);
return self();
}
public <U extends T> THIS creator(Class<? extends BeanCreator<U>> creatorClazz) {
return creator(cg -> {
BlockCreator bc = cg.createMethod();
// return new FooBeanCreator().create(syntheticCreationalContext)
MethodDesc createDesc = MethodDesc.of(BeanCreator.class, "create", Object.class, SyntheticCreationalContext.class);
bc.return_(bc.invokeInterface(createDesc, bc.new_(creatorClazz), cg.syntheticCreationalContext()));
});
}
/**
* The first method parameter is the synthetic creational context, i.e. the {@code MethodCreator#getMethodParam(0)} returns
* a {@link SyntheticCreationalContext} instance that can be used to obtain contextual references for synthetic injectionView on GitHub (pinned to e1c734241f)
Solutions
- Guard with a flag/check before calling injectInterceptionProxy, or restructure so it's invoked exactly once per configurator
- If you need different bindings, replace the configurator rather than re-adding — create a new BeanConfigurator
- Audit extension registrar implementations for duplicate registration of the same synthetic bean
Example fix
// before config.injectInterceptionProxy(BindingsA.class); if (extra) config.injectInterceptionProxy(BindingsB.class); // throws // after config.injectInterceptionProxy(extra ? BindingsB.class : BindingsA.class);
Defensive patterns
Strategy: validation
Validate before calling
if (config.interceptionProxyConfigured()) { throw new IllegalStateException("interception proxy already set"); }
config.injectInterceptionProxy(bindingsSource); Try / catch
try { config.injectInterceptionProxy(src); }
catch (DefinitionException e) { log.error("injectInterceptionProxy called twice on same configurator", e); throw e; } Prevention
- Call injectInterceptionProxy exactly once, in a single code path
- Guard shared registrar helpers against re-entry
- Review synthetic bean registrations for duplicate contribution of the same bean
When it happens
Trigger: Calling beanConfigurator.injectInterceptionProxy(...) twice on the same synthetic bean configurator — typically in shared registrar code paths executed more than once, or two extension registrations both adding an interception proxy to the same bean.
Common situations: Synthetic bean registrars with duplicated/conditional code paths; multiple extensions contributing to the same synthetic bean; copy-paste in an ObserverRegistrar/SyntheticBeanRegistrar.
Related errors
- Unable to find the bean class in the index:
- A synthetic bean ${bean} was defined with invalid scope anno
- The cause of an inactive result must also be inactive
- Creation logic not implemented
- No InterceptionProxy registered for this synthetic bean; cal
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/f836ba174425218c.
Report an issue: GitHub.