theonedev/onedev · error · org.apache.wicket.WicketRuntimeException

Method {method.getName()} of {method.getDeclaringClass()} ta

Error message

Method {method.getName()} of {method.getDeclaringClass()} targeted at {target} on component {component} threw an exception

What it means

A listener-interface method invoked reflectively threw an InvocationTargetException whose target was not a ReplaceHandlerException, AuthorizationException or WicketRuntimeException, so Wicket wraps it in a WicketRuntimeException carrying the method, target and component. The original business exception is the cause chain root.

Source

Thrown at server-core/src/main/java/org/apache/wicket/RequestListenerInterface.java:281

		// initialization is required for stateless pages
		if (!page.isInitialized())
		{
			page.internalInitialize();
		}

		try
		{
			method.invoke(target);
		}
		catch (InvocationTargetException e)
		{
			if (e.getTargetException() instanceof ReplaceHandlerException ||
				e.getTargetException() instanceof AuthorizationException ||
				e.getTargetException() instanceof WicketRuntimeException)
			{
				throw (RuntimeException)e.getTargetException();
			}
			throw new WicketRuntimeException("Method " + method.getName() + " of " +
				method.getDeclaringClass() + " targeted at " + target + " on component " +
				component + " threw an exception", e);
		}
		catch (Exception e)
		{
			throw new WicketRuntimeException("Method " + method.getName() + " of " +
				method.getDeclaringClass() + " targeted at " + target + " on component " +
				component + " threw an exception", e);
		}
	}

	/**
	 * Method to call to register this interface for use
	 */
	public void register()
	{
		// Register this listener interface
		registerRequestListenerInterface(this);

View on GitHub (pinned to d44925c47c)

Solutions

  1. Read the 'Caused by' of the WicketRuntimeException — the fix belongs to the wrapped original exception
  2. Add try/catch inside listener methods for expected business failures and convert to feedback messages via component.error(...)
  3. Wrap risky calls in a custom behavior/requestcycle listener for centralized error handling
  4. Check target/component fields in the message to locate the offending component path

Example fix

// before
button.onClick(target -> orderService.submit(order)); // raw exception escapes
// after
button.onClick(target -> {
    try { orderService.submit(order); }
    catch (ValidationException e) { form.error(e.getMessage()); target.add(form); }
});
Defensive patterns

Strategy: try-catch

Validate before calling

// validate inputs before invoking handler
if (model.getObject() == null) { form.error("Nothing selected"); return; }

Try / catch

try {
    listenerMethod.invoke(...);
} catch (WicketRuntimeException e) {
    Throwable cause = e.getCause(); // the real business exception
    log.error("Handler failed on component", cause);
}

Prevention

When it happens

Trigger: Any exception thrown inside a component listener method (onClick, onSubmit, etc.) that isn't one of Wicket's flow-control exceptions — e.g. NPE in the handler, a RuntimeException from a service call, a database error.

Common situations: NPEs from null models inside onClick; service-layer exceptions surfacing during form/Ajax handling; database constraint violations in submit handlers.

Related errors


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