Re: RequestScoped and background threads

2017-06-13 Thread Stephan Classen
The request scope uses internally a thread local. So when you run stuff in a 
background thread you are not in a request as guice sees it. You need to call 
the same method as the mentioned filter does inorder to begin and end a request.

Am 13. Juni 2017 20:21:00 MESZ schrieb Arun Thirupathi 
:
>In one of our projects we are binding an implementation in
>RequestScope. 
>But when this is run from a background thread, it fails with the
>exception 
>below. 
>
>Error in custom provider, com.google.inject.OutOfScopeException: Cannot
>
>access scoped object.
>Either we are not currently inside an HTTP Servlet request, or you may
>have 
>forgotten to apply
>com.google.inject.servlet.GuiceFilter as a servlet filter for this
>request.
>
>Can I bind different implementations based on the scope ? I want to
>provide 
>one implementation in RequestScope and other implementation in another 
>scope.
>
>Is there a way to configure Guice to ignore these errors silently. 
>
>Currently I am thinking of the naive way of, try/catch all the usage of
>
>this object, which is far too many and there are new interactions with
>this 
>object.
>
>I run my project inside Google App Engine, if that matters.
>
>Thanks,
>Arun.
>
>-- 
>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 post to this group, send email to google-guice@googlegroups.com.
>Visit this group at https://groups.google.com/group/google-guice.
>To view this discussion on the web visit
>https://groups.google.com/d/msgid/google-guice/2238b96f-0b42-408b-8bbb-08d58f3a0d1a%40googlegroups.com.
>For more options, visit https://groups.google.com/d/optout.

-- 
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 post to this group, send email to google-guice@googlegroups.com.
Visit this group at https://groups.google.com/group/google-guice.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-guice/EA5D362D-7206-443F-9AA1-CC261370124E%40gmx.ch.
For more options, visit https://groups.google.com/d/optout.


RequestScoped and background threads

2017-06-13 Thread Arun Thirupathi
In one of our projects we are binding an implementation in RequestScope. 
But when this is run from a background thread, it fails with the exception 
below. 

Error in custom provider, com.google.inject.OutOfScopeException: Cannot 
access scoped object.
Either we are not currently inside an HTTP Servlet request, or you may have 
forgotten to apply
com.google.inject.servlet.GuiceFilter as a servlet filter for this request.

Can I bind different implementations based on the scope ? I want to provide 
one implementation in RequestScope and other implementation in another 
scope.

Is there a way to configure Guice to ignore these errors silently. 

Currently I am thinking of the naive way of, try/catch all the usage of 
this object, which is far too many and there are new interactions with this 
object.

I run my project inside Google App Engine, if that matters.

Thanks,
Arun.

-- 
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 post to this group, send email to google-guice@googlegroups.com.
Visit this group at https://groups.google.com/group/google-guice.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-guice/2238b96f-0b42-408b-8bbb-08d58f3a0d1a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.