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

  1. Ensure your BuildExtension is registered and initialized (initialize(ctx) receives the context that wires the AnnotationStore)
  2. Use getAnnotationStore()/store-backed access only after initialization completes
  3. In custom harnesses, initialize BeanDeployment/AnnotationStore before invoking transformations
  4. 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

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


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/c457314273bb9ae3. Report an issue: GitHub.