{"record":{"id":"5ed31031b49b3ab0","repo":"theonedev/onedev","slug":"no-requestcycle-is-currently-set","errorCode":null,"errorMessage":"No RequestCycle is currently set!","messagePattern":"No RequestCycle is currently set!","errorType":"exception","errorClass":"WicketRuntimeException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/org/apache/wicket/Component.java","lineNumber":1839,"sourceCode":"\t * \n\t * @return If true, the component tag will not be printed\n\t */\n\tpublic final boolean getRenderBodyOnly()\n\t{\n\t\treturn getFlag(FLAG_RENDER_BODY_ONLY);\n\t}\n\n\t/**\n\t * @return The request for this component's active request cycle\n\t */\n\tpublic final Request getRequest()\n\t{\n\t\tRequestCycle requestCycle = getRequestCycle();\n\t\tif (requestCycle == null)\n\t\t{\n\t\t\t// Happens often with WicketTester when one forgets to call\n\t\t\t// createRequestCycle()\n\t\t\tthrow new WicketRuntimeException(\"No RequestCycle is currently set!\");\n\t\t}\n\t\treturn requestCycle.getRequest();\n\t}\n\n\t/**\n\t * Gets the active request cycle for this component\n\t * \n\t * @return The request cycle\n\t */\n\tpublic final RequestCycle getRequestCycle()\n\t{\n\t\treturn RequestCycle.get();\n\t}\n\n\t/**\n\t * @return The response for this component's active request cycle\n\t */\n\tpublic final Response getResponse()","sourceCodeStart":1821,"sourceCodeEnd":1857,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/org/apache/wicket/Component.java#L1821-L1857","documentation":"Component.getRequest() obtains the RequestCycle from the application's request-cycle provider. If no RequestCycle is bound to the current thread, Wicket throws this WicketRuntimeException. The framework's own comment notes this commonly happens in WicketTester when createRequestCycle() was never called.","triggerScenarios":"Calling getRequest()/getRequestCycle() outside a request thread (background job, test setup, application startup) or in WicketTester without createRequestCycle().","commonSituations":"WicketTester tests forgetting to start a page or create a request cycle; accessing request-scoped APIs from scheduled tasks/threads; code run in the init() phase of the application.","solutions":["In WicketTester tests, call tester.createRequestCycle() or start a page before touching request APIs","Move request-dependent code out of background threads; pass needed data as parameters","Guard with RequestCycle.get() null check when running in non-request contexts","Use Application.get() for app-level data instead of request-scoped lookups"],"exampleFix":"// before\nRunnable job = () -> {\n    WebSession.get().info(\"done\"); // no request cycle in worker thread\n};\n// after\nRunnable job = () -> {\n    // capture what you need before leaving the request thread\n    Session session = Session.get();\n    executor.execute(() -> session.info(\"done\"));\n};","handlingStrategy":"type-guard","validationCode":"if (RequestCycle.get() == null) {\n    // not in a request thread — skip request-scoped work\n    return;\n}","typeGuard":"boolean hasRequestCycle() {\n    return RequestCycle.get() != null;\n}","tryCatchPattern":"try {\n    component.getRequest();\n} catch (WicketRuntimeException e) {\n    if (\"No RequestCycle is currently set!\".equals(e.getMessage())) {\n        // fall back to application-level data\n    }\n}","preventionTips":["In WicketTester, call tester.startPage() or tester.createRequestCycle() before request APIs","Never touch request-scoped APIs from background threads or Application.init()","Capture needed request data before spawning async work"],"tags":["wicket","request-cycle","threading"],"backgroundTag":"resource-not-found","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"}