carnellj / spmia-chapter7

Source code for chapter 7 of Spring Microservices in Action
46 stars 133 forks source link

Can't propagate OAuth2 access token #5

Closed v8tix closed 7 years ago

v8tix commented 7 years ago

Hi John,

I'm right now trying to finish chapter 7 (Propagating the OAuth2 access token), but I'm getting this error from the console when I'm trying to call 2 services built like the organization-service:

java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.

...

hystrix.DelegatingUserContextCallable.call(DelegatingUserContextCallable.java:22) ~[classes/:na]

from postman I got this message error:

{ "timestamp": 1492724749244, "status": 500, "error": "Internal Server Error", "exception": "org.springframework.beans.factory.BeanCreationException", "message": "Error creating bean with name 'scopedTarget.oauth2ClientContext': Scope 'request' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.", "path": "/v1//" }