theonedev/onedev · error · IllegalStateException

has not been properly removed from hierachy. Something in t

Error message

 has not been properly removed from hierachy. Something in the hierarchy of 

What it means

When a component is removed from its hierarchy, Component calls onRemove() and then verifies FLAG_REMOVING_FROM_HIERARCHY was cleared; the clear happens only in Component.onRemove(). If an override does not call super.onRemove(), the flag stays set and Wicket throws this IllegalStateException (note the 'hierachy' typo is in the framework message itself).

Source

Thrown at server-core/src/main/java/org/apache/wicket/Component.java:1157

	 *            The feedback message
	 */
	public final void debug(final Serializable message)
	{
		getFeedbackMessages().debug(this, message);
		addStateChange();
	}

	/**
	 * Signals this Component that it is removed from the Component hierarchy.
	 */
	final void internalOnRemove()
	{
		setFlag(FLAG_REMOVING_FROM_HIERARCHY, true);
		onRemove();
		setFlag(FLAG_REMOVED, true);
		if (getFlag(FLAG_REMOVING_FROM_HIERARCHY))
		{
			throw new IllegalStateException(Component.class.getName() +
				" has not been properly removed from hierachy. Something in the hierarchy of " +
				getClass().getName() +
				" has not called super.onRemove() in the override of onRemove() method");
		}
		new Behaviors(this).onRemove(this);
		removeChildren();
	}

	/**
	 * Detaches the component. This is called at the end of the request for all the pages that are
	 * touched in that request.
	 */
	@Override
	public final void detach()
	{
		try
		{
			setFlag(FLAG_DETACHING, true);

View on GitHub (pinned to d44925c47c)

Solutions

  1. Find the onRemove() override in the named hierarchy
  2. Add super.onRemove() to the override
  3. Ensure no exception thrown in the override body prevents the super call (use try/finally if needed)

Example fix

// before
@Override
protected void onRemove() {
    releaseResources();
}
// after
@Override
protected void onRemove() {
    try {
        releaseResources();
    } finally {
        super.onRemove();
    }
}
Defensive patterns

Strategy: validation

Validate before calling

@Override
protected void onRemove() {
    try {
        release();
    } finally {
        super.onRemove();
    }
}

Prevention

When it happens

Trigger: An override of onRemove() omits super.onRemove(); the component is removed via remove() or parent removal.

Common situations: Custom containers releasing resources in onRemove(); overrides copied from pre-6.x Wicket code.

Related errors


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/9b94482701d4166e. Report an issue: GitHub.