quarkusio/quarkus · error · IllegalStateException
Reflection invocation error
Error message
Reflection invocation error
What it means
FieldAccessor.getValue() reads a field reflectively via field.get(instance) and wraps any reflective failure (IllegalAccessException, NPE on null instance, IllegalArgumentException for wrong type) in an IllegalStateException with message "Reflection invocation error". It indicates the accessor could not read the field at runtime.
Source
Thrown at independent-projects/qute/core/src/main/java/io/quarkus/qute/FieldAccessor.java:23
/**
*
* @see ReflectionValueResolver
*/
class FieldAccessor implements ValueAccessor, AccessorCandidate {
private final Field field;
FieldAccessor(Field field) {
this.field = field;
}
@Override
public CompletionStage<Object> getValue(Object instance) {
try {
return CompletionStageSupport.toCompletionStage(field.get(instance));
} catch (Exception e) {
throw new IllegalStateException("Reflection invocation error", e);
}
}
@Override
public ValueAccessor getAccessor(EvalContext context) {
return this;
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Ensure the class/field is registered for reflection when running in native mode (@RegisterForReflection or reflect-config.json).
- Check that the instance being evaluated is of the expected type and not null.
- In dev mode, trigger a clean restart so cached reflection accessors are rebuilt.
- Prefer generated value resolvers (compile-time) over reflection fallback by having proper bean classes/records accessible.
Example fix
// before (native image)
// no reflection config
// after
@RegisterForReflection
class MyDto { String name; }
// or add to reflect-config.json:
// {"name":"MyDto","allPublicFields":true} Defensive patterns
Strategy: try-catch
Validate before calling
Field f = instance.getClass().getDeclaredField(name);
if (!f.isAccessible() /* or try setAccessible */) { /* register for reflection */ } Type guard
boolean canReadReflectively(Object instance, String field) {
if (instance == null) return false;
try { instance.getClass().getDeclaredField(field); return true; }
catch (NoSuchFieldException e) { return false; }
} Try / catch
try {
Object v = accessor.getValue(instance).toCompletableFuture().join();
} catch (IllegalStateException ex) {
LOGGER.warn("reflective field read failed", ex.getCause());
// fallback resolver or rethrow with context
} Prevention
- Register classes for reflection (@RegisterForReflection / reflect-config.json) for native builds
- Keep generated value resolvers in play by avoiding unnecessary reflection fallbacks
- Clean-restart dev mode after class redefinition errors
- Null-check the instance before property resolution
When it happens
Trigger: Value resolvers falling back to reflection (e.g. in dev mode, tests, or native image without generated accessors) when the field is not accessible, the instance is null, or the field's class was reloaded/changed (dev mode hot reload).
Common situations: Native-image builds missing reflection registration for the target class; dev-mode class redefinition invalidating cached Field objects; accessing a field on the wrong instance type.
Related errors
- Reflection invocation error
- Unable to find handleRequest method in <handlerClass.getName
- Unable to create new instance for ${clazz}
- Unable to load class [<className>]
- No template variant found
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/2d4f9ec943fc4e1f.
Report an issue: GitHub.