{"record":{"id":"0ac612bf6c131a65","repo":"quarkusio/quarkus","slug":"cannot-obtain-injectionpoint-metadata-for-non-dep","errorCode":null,"errorMessage":"Cannot obtain InjectionPoint metadata for non-@Dependent bean","messagePattern":"Cannot obtain InjectionPoint metadata for non-@Dependent bean","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InstanceImpl.java","lineNumber":84,"sourceCode":"\n            @Override\n            public InjectableInstance<T> select(Annotation... qualifiers) {\n                return wrap(null, delegate.select(qualifiers));\n            }\n\n            @Override\n            public <U extends T> InjectableInstance<U> select(Class<U> subtype, Annotation... qualifiers) {\n                return wrap(subtype, delegate.select(subtype, qualifiers));\n            }\n\n            @Override\n            public <U extends T> InjectableInstance<U> select(TypeLiteral<U> subtype, Annotation... qualifiers) {\n                return wrap(subtype.getType(), delegate.select(subtype, qualifiers));\n            }\n\n            private <U> InjectableInstance<U> wrap(Type subtype, InjectableInstance<U> delegate) {\n                if (InjectionPoint.class.equals(subtype)) {\n                    throw new IllegalStateException(\"Cannot obtain InjectionPoint metadata for non-@Dependent bean\");\n                }\n                return new Guard<>(delegate);\n            }\n\n            @Override\n            public void clearCache() {\n                delegate.clearCache();\n            }\n\n            @Override\n            public Iterator<T> iterator() {\n                return delegate.iterator();\n            }\n\n            @Override\n            public boolean isUnsatisfied() {\n                return delegate.isUnsatisfied();\n            }","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InstanceImpl.java#L66-L102","documentation":"Instance.select() in ArC returns an InjectableInstance; when selecting for the InjectionPoint type itself, wrap() throws IllegalStateException because InjectionPoint metadata can only be injected into @Dependent beans. Obtaining InjectionPoint for a non-@Dependent bean would give metadata for a shared bean instance, which the spec forbids.","triggerScenarios":"Calling instance.select(InjectionPoint.class) (or select(TypeLiteral<InjectionPoint>) ) programmatically on an Instance obtained in a bean whose scope is not @Dependent, e.g. @ApplicationScoped or @RequestScoped.","commonSituations":"Trying to inspect injection-point metadata at runtime from a singleton bean; copying code that worked in a @Dependent bean into a normal-scoped bean.","solutions":["Only obtain InjectionPoint metadata from beans with @Dependent scope","Inject InjectionPoint directly via @Inject into a @Dependent bean instead of selecting it from Instance","Move the metadata-dependent logic into a separate @Dependent helper bean","If you need the metadata in a normal-scoped bean, create the @Dependent helper via Instance<MyHelper>() and read InjectionPoint inside it"],"exampleFix":"// before (@ApplicationScoped bean)\n@Inject Instance<InjectionPoint> ip;\nInjectionPoint metadata = ip.get();\n// after\ndependingInstance.select(InjectionPoint.class).get(); // called on a @Dependent bean's Instance","handlingStrategy":"type-guard","validationCode":"if (!beanClass.isAnnotationPresent(jakarta.enterprise.context.Dependent.class)) {\n    throw new IllegalStateException(\"InjectionPoint metadata only available in @Dependent beans\");\n}","typeGuard":"static boolean canObtainInjectionPoint(Class<?> beanClass) {\n    return beanClass.isAnnotationPresent(Dependent.class);\n}","tryCatchPattern":"try {\n    InjectionPoint ip = instance.select(InjectionPoint.class).get();\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"non-@Dependent bean\")) {\n        throw new IllegalStateException(\"Move this logic to a @Dependent bean\", e);\n    }\n    throw e;\n}","preventionTips":["Only read InjectionPoint metadata from @Dependent beans","Never select(InjectionPoint.class) from @ApplicationScoped/@RequestScoped beans","Centralize injection-point-dependent logic in a dedicated @Dependent helper"],"tags":["cdi","arc","dependency-injection","scopes"],"backgroundTag":"invalid-injection-point-access","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"}