qq_42437588 2021-08-17 17:33 采纳率: 0%
浏览 938
已结题

springcloud项目中定时任务执行远程调用有问题报错


2021-08-17 17:20:00.009 ERROR 23692 --- [   scheduling-1] o.s.s.s.TaskUtils$LoggingErrorHandler    : Unexpected error occurred in scheduled task

org.springframework.beans.factory.BeanCreationException: 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:368)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:35)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:192)
    at com.sun.proxy.$Proxy169.getAccessToken(Unknown Source)
    at org.springframework.cloud.security.oauth2.client.AccessTokenContextRelay.copyToken(AccessTokenContextRelay.java:52)
    at com.evs.my518.common.security.feign.EvsFeignClientInterceptor.apply(EvsFeignClientInterceptor.java:54)
    at feign.SynchronousMethodHandler.targetRequest(SynchronousMethodHandler.java:171)
    at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:101)
    at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:80)
    at com.alibaba.cloud.sentinel.feign.SentinelInvocationHandler.invoke(SentinelInvocationHandler.java:107)
    at com.sun.proxy.$Proxy211.getAllDeptList(Unknown Source)
    at com.evs.organ.staffmanage.service.impl.InstitutionalStatisticsServiceImpl.save(InstitutionalStatisticsServiceImpl.java:65)
    at com.evs.organ.staffmanage.service.impl.InstitutionalStatisticsServiceImpl$$FastClassBySpringCGLIB$$513d0be5.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:685)
    at com.evs.organ.staffmanage.service.impl.InstitutionalStatisticsServiceImpl$$EnhancerBySpringCGLIB$$bfc17c79.save(<generated>)
    at com.evs.organ.staffmanage.config.InstitutionSave.Save(InstitutionSave.java:25)
    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 org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84)
    at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
    at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:93)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266)
    at java.util.concurrent.FutureTask.run(FutureTask.java)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
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:356)
    ... 32 common frames omitted


![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/384647291926155.png 'image.png')


  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 8月25日
    • 创建了问题 8月17日

    悬赏问题

    • ¥15 系统 24h2 专业工作站版,浏览文件夹的图库,视频,图片之类的怎样删除?
    • ¥15 怎么把512还原为520格式
    • ¥15 MATLAB的动态模态分解出现错误,以CFX非定常模拟结果为快照
    • ¥15 求高通平台Softsim调试经验
    • ¥15 canal如何实现将mysql多张表(月表)采集入库到目标表中(一张表)?
    • ¥15 wpf ScrollViewer实现冻结左侧宽度w范围内的视图
    • ¥15 栅极驱动低侧烧毁MOSFET
    • ¥30 写segy数据时出错3
    • ¥100 linux下qt运行QCefView demo报错
    • ¥50 F1C100S下的红外解码IR_RX驱动问题