永恒奔跑,寻理持 2023-04-12 17:43 采纳率: 100%
浏览 92
已结题

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

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

  • 写回答

3条回答 默认 最新

  • a1767028198 2023-04-12 18:07
    关注

    定时任务怎么会有request

    img

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 4月23日
  • 已采纳回答 4月15日
  • 修改了问题 4月13日
  • 创建了问题 4月12日

悬赏问题

  • ¥15 prism提示我reinstall prism 如何解决
  • ¥15 asp.core 权限控制怎么做,需要控制到每个方法
  • ¥20 while循环中OLED显示中断中的数据不正确
  • ¥15 这个视频里的stm32f4代码是怎么写的
  • ¥15 JNA调用DLL报堆栈溢出错误(0xC00000FD)
  • ¥15 请教SGeMs软件的使用
  • ¥15 自己用vb.net编写了一个dll文件,如何只给授权的用户使用这个dll文件进行打包编译,未授权用户不能进行打包编译操作?
  • ¥50 深度学习运行代码直接中断
  • ¥20 需要完整的共散射点成像代码
  • ¥15 编写vba代码实现数据录入工作