theonedev/onedev · error · WicketRuntimeException
No RequestCycle is currently set!
Error message
No RequestCycle is currently set!
What it means
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.
Source
Thrown at server-core/src/main/java/org/apache/wicket/Component.java:1839
*
* @return If true, the component tag will not be printed
*/
public final boolean getRenderBodyOnly()
{
return getFlag(FLAG_RENDER_BODY_ONLY);
}
/**
* @return The request for this component's active request cycle
*/
public final Request getRequest()
{
RequestCycle requestCycle = getRequestCycle();
if (requestCycle == null)
{
// Happens often with WicketTester when one forgets to call
// createRequestCycle()
throw new WicketRuntimeException("No RequestCycle is currently set!");
}
return requestCycle.getRequest();
}
/**
* Gets the active request cycle for this component
*
* @return The request cycle
*/
public final RequestCycle getRequestCycle()
{
return RequestCycle.get();
}
/**
* @return The response for this component's active request cycle
*/
public final Response getResponse()View on GitHub (pinned to d44925c47c)
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
Example fix
// before
Runnable job = () -> {
WebSession.get().info("done"); // no request cycle in worker thread
};
// after
Runnable job = () -> {
// capture what you need before leaving the request thread
Session session = Session.get();
executor.execute(() -> session.info("done"));
}; Defensive patterns
Strategy: type-guard
Validate before calling
if (RequestCycle.get() == null) {
// not in a request thread — skip request-scoped work
return;
} Type guard
boolean hasRequestCycle() {
return RequestCycle.get() != null;
} Try / catch
try {
component.getRequest();
} catch (WicketRuntimeException e) {
if ("No RequestCycle is currently set!".equals(e.getMessage())) {
// fall back to application-level data
}
} Prevention
- 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
When it happens
Trigger: Calling getRequest()/getRequestCycle() outside a request thread (background job, test setup, application startup) or in WicketTester without createRequestCycle().
Common situations: 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.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Wicket Session object not available
- Page classes should extend from BasePage.
- Base resource mapper should be used
- Invalid date range, expecting "yyyy-MM-dd to yyyy-MM-dd"
- Path '${mountPath}' should be mounted to a svg sprite resour
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/5ed31031b49b3ab0.
Report an issue: GitHub.