title: Spring Boot: Unable to access the request scope bean in Spring Scheduler
body: <p>In my Spring Boot application, i've a Scheduler task which executes for every one hour. In the scheduler method trying to access the request-scope bean. Always getting the exception <strong>org.springframework.beans.factory.BeanCreationException</strong>.</p>
  <p>Here is the code sample.</p>
  <pre><code>@Data
  public class TestVo {
    private String message = &quot;Hello&quot;;
  }
  
  @Bean
  @Scope(value=&quot;request&quot;, proxyMode=ScopedProxyMode.TARGET_CLASS)
  public TestVo testVo() {
      return new TestVo();
  }
  </code></pre>
  <p>Accessing the above created bean in scheduler method as below,</p>
  <pre><code>@Autowired
  private TestVo testVo;
  
  @Scheduled(cron=&quot;0 0 * * * *&quot;)
  public void greetings() {
    System.out.println(testVo.getMessage()); // accessing request scope bean
  }
  </code></pre>
  <p>getting below exception with above code,</p>
  <blockquote>
  <p>org.springframework.beans.factory.BeanCreationException: Error
  creating bean with name 'scopedTarget.scheduledJobTaskExecutor': 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: In this case, use
  RequestContextListener or RequestContextFilter to expose the current
  request.</p>
  </blockquote>