微服务定时任务调用网站接口报错

2023-04-13 08:45:25 [com.xxl.job.core.thread.JobThread#run]-[133]-[xxl-job, JobThread-8-1681346725781] 
----------- xxl-job job execute start -----------
----------- Param:
2023-04-13 08:45:25 [com.xxl.job.core.thread.JobThread#run]-[204]-[xxl-job, JobThread-8-1681346725781] 
----------- JobThread Exception:java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.xxl.job.core.handler.impl.MethodJobHandler.execute(MethodJobHandler.java:31)
    at com.xxl.job.core.thread.JobThread.run(JobThread.java:166)
Caused by: org.springframework.beans.factory.support.ScopeNotActiveException: 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: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:383)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
    at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:35)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:195)
    at com.sun.proxy.$Proxy164.getAccessToken(Unknown Source)
    at org.springframework.cloud.commons.security.AccessTokenContextRelay.copyToken(AccessTokenContextRelay.java:52)
    at com.lutao.haspm.common.security.interceptor.HaspmFeignClientInterceptor.apply(HaspmFeignClientInterceptor.java:51)
    at feign.SynchronousMethodHandler.targetRequest(SynchronousMethodHandler.java:161)
    at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:110)
    at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:89)
    at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:100)
    at com.sun.proxy.$Proxy238.getAccessToken(Unknown Source)
    at com.lutao.haspm.admin.service.impl.OrganizationInfoServiceImpl.getAccessToken(OrganizationInfoServiceImpl.java:63)
    at com.lutao.haspm.admin.service.impl.OrganizationInfoServiceImpl.syncGet(OrganizationInfoServiceImpl.java:81)
    at com.lutao.haspm.admin.service.impl.OrganizationInfoServiceImpl.getSyncBody(OrganizationInfoServiceImpl.java:120)
    at com.lutao.haspm.admin.service.impl.OrganizationInfoServiceImpl.handlerOrganizationInfo(OrganizationInfoServiceImpl.java:146)
    at com.lutao.haspm.admin.service.impl.OrganizationInfoServiceImpl$$FastClassBySpringCGLIB$$31344ab7.invoke()
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689)
    at com.lutao.haspm.admin.service.impl.OrganizationInfoServiceImpl$$EnhancerBySpringCGLIB$$1e9cebfa.handlerOrganizationInfo()
    at com.lutao.haspm.admin.job.OrganizationInfoJobHandler.organizationInfoJobHandler(OrganizationInfoJobHandler.java:20)
    ... 6 more
Caused by: 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.
    at org.springframework.web.context.request.RequestContextHolder.currentRequestAttributes(RequestContextHolder.java:131)
    at org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:42)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:371)
    ... 26 more

----------- xxl-job job execute end(error) -----------
2023-04-13 08:45:25 [com.xxl.job.core.thread.TriggerCallbackThread#callbackLog]-[197]-[xxl-job, executor TriggerCallbackThread] 
----------- xxl-job job callback finish.

[Load Log Finish]

定时任务job在浏览器上执行定时任务报的执行任务的错误(上面代码),试了好多方法都没有解决?谁来帮帮我啦,万分感谢

定时任务怎么会有request

img

大概率定时任务里面调用的方法间接执行了获取httpservletrequest这种操作导致空指针吧

img

上面是项目控制台定时任务Xxx-job输出的,我暂时没弄太懂。就是http://localhost:9007/haspm-job-admin/%E5%9C%B0%E5%9D%80%E6%89%A7%E8%A1%8C%E5%AE%9A%E6%97%B6%E4%BB%BB%E5%8A%A1%E6%8A%A5%E7%9A%84%E6%89%A7%E8%A1%8C%E6%97%A5%E5%BF%97%E9%94%99%E8%AF%AF%EF%BC%9F%E8%83%BD%E7%BB%99%E6%88%91%E8%AF%B4%E4%B8%AA%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95%E5%90%97%EF%BC%9F%E4%B8%87%E5%88%86%E6%84%9F%E8%B0%A2