{"record":{"id":"d4812cac10d213c4","repo":"theonedev/onedev","slug":"method-method-getname-of-method-getdeclaringc","errorCode":null,"errorMessage":"Method {method.getName()} of {method.getDeclaringClass()} targeted at {target} on component {component} threw an exception","messagePattern":"Method (.+?) of (.+?) targeted at (.+?) on component (.+?) threw an exception","errorType":"exception","errorClass":"org.apache.wicket.WicketRuntimeException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/org/apache/wicket/RequestListenerInterface.java","lineNumber":281,"sourceCode":"\t\t// initialization is required for stateless pages\n\t\tif (!page.isInitialized())\n\t\t{\n\t\t\tpage.internalInitialize();\n\t\t}\n\n\t\ttry\n\t\t{\n\t\t\tmethod.invoke(target);\n\t\t}\n\t\tcatch (InvocationTargetException e)\n\t\t{\n\t\t\tif (e.getTargetException() instanceof ReplaceHandlerException ||\n\t\t\t\te.getTargetException() instanceof AuthorizationException ||\n\t\t\t\te.getTargetException() instanceof WicketRuntimeException)\n\t\t\t{\n\t\t\t\tthrow (RuntimeException)e.getTargetException();\n\t\t\t}\n\t\t\tthrow new WicketRuntimeException(\"Method \" + method.getName() + \" of \" +\n\t\t\t\tmethod.getDeclaringClass() + \" targeted at \" + target + \" on component \" +\n\t\t\t\tcomponent + \" threw an exception\", e);\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tthrow new WicketRuntimeException(\"Method \" + method.getName() + \" of \" +\n\t\t\t\tmethod.getDeclaringClass() + \" targeted at \" + target + \" on component \" +\n\t\t\t\tcomponent + \" threw an exception\", e);\n\t\t}\n\t}\n\n\t/**\n\t * Method to call to register this interface for use\n\t */\n\tpublic void register()\n\t{\n\t\t// Register this listener interface\n\t\tregisterRequestListenerInterface(this);","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/org/apache/wicket/RequestListenerInterface.java#L263-L299","documentation":"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.","triggerScenarios":"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.","commonSituations":"NPEs from null models inside onClick; service-layer exceptions surfacing during form/Ajax handling; database constraint violations in submit handlers.","solutions":["Read the 'Caused by' of the WicketRuntimeException — the fix belongs to the wrapped original exception","Add try/catch inside listener methods for expected business failures and convert to feedback messages via component.error(...)","Wrap risky calls in a custom behavior/requestcycle listener for centralized error handling","Check target/component fields in the message to locate the offending component path"],"exampleFix":"// before\nbutton.onClick(target -> orderService.submit(order)); // raw exception escapes\n// after\nbutton.onClick(target -> {\n    try { orderService.submit(order); }\n    catch (ValidationException e) { form.error(e.getMessage()); target.add(form); }\n});","handlingStrategy":"try-catch","validationCode":"// validate inputs before invoking handler\nif (model.getObject() == null) { form.error(\"Nothing selected\"); return; }","typeGuard":null,"tryCatchPattern":"try {\n    listenerMethod.invoke(...);\n} catch (WicketRuntimeException e) {\n    Throwable cause = e.getCause(); // the real business exception\n    log.error(\"Handler failed on component\", cause);\n}","preventionTips":["Always inspect getCause() of WicketRuntimeException","Catch expected business exceptions inside listener methods and report via component.error()","Register an AbstractRequestCycleListener for centralized handler error handling"],"tags":["wicket","wrapped-exception","listener"],"backgroundTag":"wrapped-exception-caused-by","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}