quarkusio/quarkus · error · IllegalStateException
Attempted to use the getAllAnnotations() method but Annotati
Error message
Attempted to use the getAllAnnotations() method but AnnotationStore wasn't initialized.
What it means
AnnotationsTransformationContext.getAllAnnotations()/getAllTargetAnnotations() require the AnnotationStore build extension key to be initialized in the build context. If no AnnotationStore was registered (i.e. no BuildExtension providing ANNOTATION_STORE is active), the context throws IllegalStateException. This is an internal invariant: annotation transformation extensions can only read annotations through the store.
Source
Thrown at independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/AnnotationsTransformationContext.java:79
}
void setAnnotations(C annotations) {
LOG.tracef("Annotations of %s transformed: %s", target, annotations);
this.annotations = annotations;
}
public Collection<AnnotationInstance> getAllAnnotations() {
return getAllAnnotationForTarget(getTarget());
}
public Collection<AnnotationInstance> getAllTargetAnnotations() {
return getAllAnnotationForTarget(getAnnotationTarget());
}
private Collection<AnnotationInstance> getAllAnnotationForTarget(AnnotationTarget target) {
AnnotationStore annotationStore = get(BuildExtension.Key.ANNOTATION_STORE);
if (annotationStore == null) {
throw new IllegalStateException(
"Attempted to use the getAllAnnotations() method but AnnotationStore wasn't initialized.");
}
// Jandex overlay in compatible mode won't allow us to query for METHOD_PARAMETER
// hence if the "target" is method param, we query whole method and filter it
if (AnnotationTarget.Kind.METHOD_PARAMETER.equals(target.kind())) {
return Annotations.getParameterAnnotations(annotationStore::getAnnotations,
target.asMethodParameter().method(), target.asMethodParameter().position());
} else {
return annotationStore.getAnnotations(target);
}
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Ensure your BuildExtension is registered and initialized (initialize(ctx) receives the context that wires the AnnotationStore)
- Use getAnnotationStore()/store-backed access only after initialization completes
- In custom harnesses, initialize BeanDeployment/AnnotationStore before invoking transformations
- Prefer AnnotationStore.getAnnotations(target) via a properly provided key rather than bypassing registration
Example fix
// before
public void transform(TransformationContext ctx) { ctx.getAllAnnotations(); } // store missing
// after
public boolean initialize(BuildContext ctx) { this.ctx = ctx; return true; }
public void transform(TransformationContext tc) { this.ctx.get(BuildExtension.Key.ANNOTATION_STORE); ... } Defensive patterns
Strategy: validation
Validate before calling
AnnotationStore store = ctx.get(BuildExtension.Key.ANNOTATION_STORE);
if (store == null) throw new IllegalStateException("Initialize your BuildExtension before using getAllAnnotations()"); Type guard
static boolean storeReady(BuildContext ctx) { return ctx.get(BuildExtension.Key.ANNOTATION_STORE) != null; } Try / catch
try { annotations = ctx.getAllAnnotations(); }
catch (IllegalStateException e) { log.warn("AnnotationStore unavailable; falling back to target.raw annotations"); } Prevention
- Only call getAllAnnotations() from within extension callbacks after initialize(ctx)
- Return true from BuildExtension.initialize() when you intend to use store-backed APIs
- In custom harnesses, initialize BeanDeployment before transformations
When it happens
Trigger: A custom BuildExtension/AnnotationTransformer calls ctx.getAllAnnotations() or getAllTargetAnnotations() while the AnnotationStore isn't part of the build (e.g. extension not properly registered/initialized, or transformation context used outside a deployment where the store is set up).
Common situations: Writing a custom Arc annotation transformer extension; using the transformation context in a test harness without the full BeanDeployment initialization; BuildExtension priority/registration mistakes.
Related errors
- Quarkus does not support CDI Full @Specializes annotation; t
- IllegalStateException wrapping ClassNotFoundException for ge
- Unable to derive the logger name at ${injectionPoint}
- Improper integration of '${LogFilterFactory.class.getName()}
- No TCCL available
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/c457314273bb9ae3.
Report an issue: GitHub.