Hi Ganish, were you (or anyone else) able to figure out how to get this
working?
Oddly enough, when I only have one async call,
the com.google.inject.servlet.RequestScoped does not have an issue. It's
only when I add a second async call and link it with the first one using
thenCombine, do I run into
[java] com.google.inject.ProvisionException: Unable to provision, see the
following errors: [java] [java] 1) [Guice/ErrorInCustomProvider]:
OutOfScopeException: Cannot access Key[type=FooContext, annotation=[none]]
outside of a scoping block [java] at
BarModule.createFooContext(BarModule.java:) [java] while locating
FooContext [java] [java] Learn more: [java]
https://github.com/google/guice/wiki/ERROR_IN_CUSTOM_PROVIDER [java] [java]
1 error
I tried following https://stackoverflow.com/a/33945302/23282628 but I just
get "Not in a request scope" error as a result when trying to use
ServletScopes.transferRequest
On Saturday 13 May 2017 at 17:28:47 UTC-5 Ganesh J wrote:
> Hi
>
>
> We are using Guice 4.1 in out Jetty based web applications. We are
> exposing APIs through jersey 1.19.3. We are using
> com.google.inject.servlet.GuiceFilter in our web.xml to intercept all
> requests. Now we do have couple of request scopes beans defined. Also we
> have within a single request processing flow multiple thread hops: Main
> Jetty thread -> FIrst thread -> Second thread. Request scope objects are
> injected using Provider to classes that are invoked from second thread. So
> to make that work we wrapped the callable submitted to first thread using
> ServletScopes.transferRequest. The to transfer scope to second tread we
> tried wrapping callable submitted to second thread by
> ServletScopes.transferRequest. Now when this is executed the execution is
> blocked. When we referred to the javadoc for ServletScopes.transferRequest
>
>
> "Because request-scoped objects are not typically thread-safe, the
> callable returned by this method must not be run on a different thread
> until the current request scope has terminated. The returned callable will
> block until the current thread has released the request scope."
>
>
> It is a bit confusing why this is happening only to the second callable.
> The argument of thread safety can also be made for the first callable.
>
>
> We are kind of stuck here. Any suggestions on the right approach to
> propagate scope would help immensely here
>
>
> Thanks
> Ganesh
>
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to google-guice+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-guice/5a6f7928-a5d5-4f26-b24b-de342d1e7ee7n%40googlegroups.com.