kkelleher (18) [Avatar] Offline

I've been shadowing the examples, creating my own version of the licence/organization. Now, as I shadow chapter 7 and am having an error trying to get OAuth Security & Hystrix working together.

I get the following error
  "timestamp": 1494862575049,
  "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/pupils/f3831f8c-c338-4ebe-a82a-e2fc1d1ff78a"

Effectively the error occurs on line with #B below
package com.thoughtmechanix.licenses.clients;
//Removed for conciseness
public class OrganizationRestTemplateClient {
OAuth2RestTemplate restTemplate; //#A
private static final Logger logger =
public Organization getOrganization(String organizationId){
logger.debug("In Licensing Service.getOrganization: {}",
ResponseEntity<Organization> restExchange = //#B
null, Organization.class, organizationId);
/*Save the record from cache*/
return restExchange.getBody();

Can I get a pointer please ....


557915 (2) [Avatar] Offline
I stuck with the same issue, have you found any solution for this?
For now i am not using the OAuth2RestTemplate and using default RestTemplate and forwarding the Authorization header via HystrixConcurrenryStrategy mechanism.