quarkusio/quarkus · error · RuntimeException
Failed to initialize
Error message
Failed to initialize
What it means
GetterAccessorsContainerRecorder.addAccessor runs at build/record time: it instantiates a generated accessor class and registers it in the runtime container. Any exception (class not found, instantiation failure, reflection error) is wrapped in RuntimeException 'Failed to initialize <accessorName>: <cause>'.
Source
Thrown at extensions/resteasy-reactive/rest-links/runtime/src/main/java/io/quarkus/resteasy/reactive/links/runtime/GetterAccessorsContainerRecorder.java:30
public RuntimeValue<GetterAccessorsContainer> newContainer() {
return new RuntimeValue<>(new GetterAccessorsContainer());
}
/**
* Add a getter accessor to a container.
*/
public void addAccessor(RuntimeValue<GetterAccessorsContainer> container, String className, String fieldName,
String accessorName) {
try {
// Create a new accessor object early
GetterAccessor accessor = (GetterAccessor) Thread.currentThread()
.getContextClassLoader()
.loadClass(accessorName)
.getDeclaredConstructor()
.newInstance();
container.getValue().put(className, fieldName, accessor);
} catch (Exception e) {
throw new RuntimeException("Failed to initialize " + accessorName + ": " + e.getMessage());
}
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Run a clean full build (./mvnw clean install -Dquickly or clean in dev mode) to regenerate accessor classes.
- Check the wrapped cause message for the real reflection failure and fix that (e.g. missing class, no no-arg constructor).
- If in dev mode, restart quarkus:dev to clear stale generated classes.
Example fix
# before: stale incremental build ./mvnw install # after ./mvnw clean install -Dquickly
Defensive patterns
Strategy: try-catch
Validate before calling
// usually not user-fixable; guard startup checkState(generatedAccessorAvailable)
Try / catch
catch (e: RuntimeException) {
if (e.message?.startsWith("Failed to initialize") == true) {
logger.error("Accessor init failed (${e.message}); do a clean rebuild")
}
throw e
} Prevention
- Avoid stale incremental builds; clean after refactors
- Read the wrapped cause for the real error
- Restart dev mode when generated-code state looks inconsistent
When it happens
Trigger: Bytecode-generated accessor class cannot be loaded or instantiated — typically from a stale/partial build output, or the generated class was skipped (e.g. after a failed incremental build), or its no-arg constructor is unavailable.
Common situations: Incremental-build corruption after refactoring entities; IDE/Quarkus dev-mode stale state; multi-module builds where the deployment module output is outdated.
Related errors
- Invalid Flyway callback. It shouldn't be abstract and must h
- Unable to instantiate SectionHelperFactory: <engineConfigCla
- Unable to instantiate ParserHook: <engineConfigClass>
- Unable to handle class: ${applicationClass}
- Class '%s' was not found
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/4e69ce322852555a.
Report an issue: GitHub.