{"record":{"id":"82dd5ecf214d74be","repo":"quarkusio/quarkus","slug":"no-current-injection-point-found-82dd5e","errorCode":null,"errorMessage":"No current injection point found","messagePattern":"No current injection point found","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/smallrye-jwt/runtime/src/main/java/io/quarkus/smallrye/jwt/runtime/auth/RawOptionalClaimCreator.java","lineNumber":20,"sourceCode":"\nimport java.util.Map;\nimport java.util.Optional;\n\nimport jakarta.enterprise.context.spi.CreationalContext;\nimport jakarta.enterprise.inject.spi.InjectionPoint;\n\nimport io.quarkus.arc.Arc;\nimport io.quarkus.arc.BeanCreator;\nimport io.quarkus.arc.impl.InjectionPointProvider;\nimport io.smallrye.jwt.auth.cdi.RawClaimTypeProducer;\n\npublic class RawOptionalClaimCreator implements BeanCreator<Optional<?>> {\n\n    @Override\n    public Optional<?> create(CreationalContext<Optional<?>> creationalContext, Map<String, Object> params) {\n        InjectionPoint injectionPoint = InjectionPointProvider.getCurrent(creationalContext);\n        if (injectionPoint == null) {\n            throw new IllegalStateException(\"No current injection point found\");\n        }\n        RawClaimTypeProducer rawClaimTypeProducer = Arc.container().instance(RawClaimTypeProducer.class).get();\n        return rawClaimTypeProducer.getOptionalValue(injectionPoint);\n    }\n\n}\n","sourceCodeStart":2,"sourceCodeEnd":27,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/smallrye-jwt/runtime/src/main/java/io/quarkus/smallrye/jwt/runtime/auth/RawOptionalClaimCreator.java#L2-L27","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inject Optional<T> claim values via @Inject into a bean field, constructor, or method parameter instead of programmatic lookup","If programmatic lookup is required, inject into a wrapper bean and call that bean instead of resolving Optional directly","Ensure any custom BeanCreator/producer code runs within a normal injection so InjectionPointProvider.getCurrent(creationalContext) resolves"],"exampleFix":"// before\nOptional<Set<String>> roles = Arc.container().instance(Optional.class).get();\n// after\npublic class MyService {\n    @Inject\n    Optional<JsonWebToken> token;\n}","handlingStrategy":"validation","validationCode":"InjectionPoint ip = InjectionPointProvider.getCurrent(creationalContext);\nif (ip == null) { throw new IllegalStateException(\"Call must originate from a CDI injection point\"); }","typeGuard":"boolean hasInjectionPoint(CreationalContext<?> ctx) { return InjectionPointProvider.getCurrent(ctx) != null; }","tryCatchPattern":"try { Optional<?> v = instance.get(); } catch (IllegalStateException e) { /* use @Inject in a bean instead of programmatic lookup */ }","preventionTips":["Always inject Optional claims via @Inject rather than Instance.get() programmatic lookup","Never resolve producer beans during app startup outside an injection context","Wrap custom lookups in helper beans that receive the injection properly"],"tags":["cdi","jwt","dependency-injection"],"backgroundTag":"missing-injection-point","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}