quarkusio/quarkus · error · IllegalStateException

No current injection point found

Error message

No current injection point found

What it means

RawOptionalClaimCreator is the ArC BeanCreator used to produce Optional<T> injections of JWT claims. It relies on an InjectionPoint being available on the current CreationalContext to know which claim (and type) to produce. If no injection point is on the context, creating an Optional claim has no meaning, so it throws IllegalStateException.

Source

Thrown at extensions/smallrye-jwt/runtime/src/main/java/io/quarkus/smallrye/jwt/runtime/auth/RawOptionalClaimCreator.java:20

import java.util.Map;
import java.util.Optional;

import jakarta.enterprise.context.spi.CreationalContext;
import jakarta.enterprise.inject.spi.InjectionPoint;

import io.quarkus.arc.Arc;
import io.quarkus.arc.BeanCreator;
import io.quarkus.arc.impl.InjectionPointProvider;
import io.smallrye.jwt.auth.cdi.RawClaimTypeProducer;

public class RawOptionalClaimCreator implements BeanCreator<Optional<?>> {

    @Override
    public Optional<?> create(CreationalContext<Optional<?>> creationalContext, Map<String, Object> params) {
        InjectionPoint injectionPoint = InjectionPointProvider.getCurrent(creationalContext);
        if (injectionPoint == null) {
            throw new IllegalStateException("No current injection point found");
        }
        RawClaimTypeProducer rawClaimTypeProducer = Arc.container().instance(RawClaimTypeProducer.class).get();
        return rawClaimTypeProducer.getOptionalValue(injectionPoint);
    }

}

View on GitHub (pinned to e1c734241f)

Solutions

  1. Inject Optional<T> claim values via @Inject into a bean field, constructor, or method parameter instead of programmatic lookup
  2. If programmatic lookup is required, inject into a wrapper bean and call that bean instead of resolving Optional directly
  3. Ensure any custom BeanCreator/producer code runs within a normal injection so InjectionPointProvider.getCurrent(creationalContext) resolves

Example fix

// before
Optional<Set<String>> roles = Arc.container().instance(Optional.class).get();
// after
public class MyService {
    @Inject
    Optional<JsonWebToken> token;
}
Defensive patterns

Strategy: validation

Validate before calling

InjectionPoint ip = InjectionPointProvider.getCurrent(creationalContext);
if (ip == null) { throw new IllegalStateException("Call must originate from a CDI injection point"); }

Type guard

boolean hasInjectionPoint(CreationalContext<?> ctx) { return InjectionPointProvider.getCurrent(ctx) != null; }

Try / catch

try { Optional<?> v = instance.get(); } catch (IllegalStateException e) { /* use @Inject in a bean instead of programmatic lookup */ }

Prevention

When it happens

Trigger: Calling the producer programmatically (e.g. Arc.container().instance(...).get() or Instance.select(...).get()) instead of injecting an Optional claim into a bean; injecting Optional claims from non-CDI code; obtaining the Optional bean during startup where no injection point context exists.

Common situations: Programmatic lookup of Optional<JsonWebToken> or Optional claim values in tests or utility code; reflection-based instantiation; calling the bean from a non-injected context like a scheduled task constructed manually.

Related errors


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