theonedev/onedev · error · java.lang.IllegalStateException
This method is only meant to be invoked on the component whe
Error message
This method is only meant to be invoked on the component where the parameter component==this
What it means
Component.renderHead(Component component, IHeaderResponse response) from IHeaderContributor must only be invoked with the component itself as the first argument. Wicket enforces this with an IllegalStateException to catch frameworks or custom code that pass a different component, which would render headers in the wrong context.
Source
Thrown at server-core/src/main/java/org/apache/wicket/Component.java:4561
public boolean canCallListenerInterface(Method method)
{
return isEnabledInHierarchy() && isVisibleInHierarchy();
}
/**
* CAUTION: this method is not meant to be overridden like it was in wicket 1.4 when
* implementing {@link IHeaderContributor}. overload
* {@link Component#renderHead(org.apache.wicket.markup.head.IHeaderResponse)} instead to
* contribute to the response header.
*
* @param component
* @param response
*/
public final void renderHead(Component component, IHeaderResponse response)
{
if (component != this)
{
throw new IllegalStateException(
"This method is only meant to be invoked on the component where the parameter component==this");
}
renderHead(response);
}
/**
* Render to the web response whatever the component wants to contribute to the head section.
*
* @param response
* Response object
*/
@Override
public void renderHead(IHeaderResponse response)
{
// noop
}
/** {@inheritDoc} */View on GitHub (pinned to d44925c47c)
Solutions
- Pass the same component instance: component.renderHead(component, response).
- Prefer overriding renderHead(IHeaderResponse) on the component and let the framework call it, rather than invoking it manually.
- If delegating between components, call the other component's renderHead on that component itself.
Example fix
// before other.renderHead(this, response); // wrong component // after this.renderHead(response); // or: other.renderHead(other, response);
Defensive patterns
Strategy: validation
Validate before calling
if (component != this) { throw new IllegalArgumentException("renderHead must be called with this component"); } Try / catch
try { c.renderHead(c, response); } catch (IllegalStateException e) { c.renderHead(response); } Prevention
- Let the framework invoke renderHead; avoid calling it manually.
- When delegating, always call renderHead on the component that implements it, passing that same instance.
- Prefer overriding the single-argument renderHead(IHeaderResponse).
When it happens
Trigger: Manually calling component.renderHead(otherComponent, response) inside onRender/onComponentTag or from a behavior with the wrong component reference; custom header contribution pipelines passing a parent/child component.
Common situations: Custom render strategies or third-party integrations invoking IHeaderContributor directly; copy-pasted renderHead delegation code passing the wrong `this` reference; behaviors calling renderHead with the behavior's host mismatched.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- has not been properly detached. Something in the hierarchy
- has not been properly rendered. Something in the hierarchy
- Markup not found for Component:
- Markup not found. Component:
- Markup id set on a component that renders its body only. Mar
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/8db60aef7e690fa8.
Report an issue: GitHub.