Dne 29. 07. 19 v 15:07 William Burke napsal(a):
> I switched to @Dependent. Sorry for ignorance.
>
> Still, I don't understand @ActivateRequestContext . Should that let you
> NOT set a request context before invoking the method?
Yes, @ActivateRequestContext is an interceptor binding for which an
container provides an interceptor that should activate the request
context before the method is invoked (unless the request is already active).
Hm, but now I think I finally understand the problem. You can't use the
binding on the bean class itself, e.g.:
@RequestScoped
class MyBean {
@ActivateRequestContext // --> failure, the proxy needs to get the
bean instance from the context first...
void ping() {
...
}
}
It's not very obvious but I think it's implied. Using the spec wording:
"every time a method of the bean is invoked upon a client proxy, the
client proxy must obtain a contextual instance of the bean..." and "The
container must obtain the active context object for the bean scope, then
obtain an instance of the bean by calling Context.get()". [1]
But there is no active context because interceptors were not applied
yet, at least in ArC. Actually, I'm not so sure about Weld but I assume
that it would be the same since it's also using subclasess for
interceptors. @manovotn am I right?
Martin
[1]
https://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#client_proxy_invocation
>
> On Fri, Jul 26, 2019 at 11:22 AM William Burke <
bbu...@redhat.com
> <mailto:
bbu...@redhat.com>> wrote:
>
> I'm trying to do reflection on a bean annotated with @RequestScope
> and @ActivateRequestContext. This works within a @QuarkusTest, but
> not in my program. Ideas?
>
> pseudo code:
>
> Class myClass = ...;
> Method methodOnMyClass = ...;
> Object target = BeanContainer.instance(myClass);
> method.invoke(target, params);
>
> Caused by: javax.enterprise.context.ContextNotActiveException:
> interface javax.enterprise.context.RequestScoped
> at
> io.quarkus.Function_ClientProxy.arc$delegate(Function_ClientProxy.zig:131)
> at io.quarkus.Function_ClientProxy.run(Function_ClientProxy.zig:55)
>
> --
> Bill Burke
> Red Hat
>
>
>
> --
> Bill Burke
> Red Hat
>
> --
> You received this message because you are subscribed to the Google
> Groups "Quarkus Development mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
quarkus-dev...@googlegroups.com
> <mailto:
quarkus-dev...@googlegroups.com>.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/quarkus-dev/CAL%3DE%3DjSDEgqqSTyNo4SPg-8LK2Wkj_Oz4b9tPp3owCYeBfA2VA%40mail.gmail.com
> <
https://groups.google.com/d/msgid/quarkus-dev/CAL%3DE%3DjSDEgqqSTyNo4SPg-8LK2Wkj_Oz4b9tPp3owCYeBfA2VA%40mail.gmail.com?utm_medium=email&utm_source=footer>.