在下面的代码中
@Async
public void DoAsynOperation(String param) {
restTemplate.exchange("URL", HttpMethod.PUT, entity,Object.class, parameters);
}
从任何函数调用时都会说
@Override
public void callingFunction(String abc) {
DoAsynOperation(abc);
}
我遇到这样的错误
[dispatcherServlet]:Servlet的Servlet.service() 路径为[]的上下文中的[dispatcherServlet]引发了异常[Request 处理失败;]
在com.XXXXXXXXX:执行异步操作时出错 在com.XXXXXXXX(MyClass.java:688)〜[classes!/:1.0.1] 在com.XXXXXXXX.MyClass $$ FastClassBySpringCGLIB $$ 8a88bc29.invoke()〜[classes!/:1.0.1] 在org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)〜[spring-core-4.3.3.RELEASE.jar!/:4.3.3.RELEASE] 在org.springframework.aop.framework.CglibAopProxy $ CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720)〜[spring-aop-4.3.3.RELEASE.jar!/:4.3.3.RELEASE] 在org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)〜[spring-aop-4.3.3.RELEASE.jar!/:4.3.3.RELEASE] 在org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)〜[spring-aop-4.3.3.RELEASE.jar!/:4.3.3.RELEASE] 在org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)〜[spring-aop-4.3.3.RELEASE.jar!/:4.3.3.RELEASE] 在org.springframework.aop.framework.CglibAopProxy $ DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655)〜[spring-aop-4.3.3.RELEASE.jar!/:4.3.3.RELEASE] 在com.XXXXXXXXX $$ EnhancerBySpringCGLIB $$ 861169fd.inwardMedicine()〜[classes!/:1.0.1] 在com.controller.XXXXXXXXXXXXX(MyController.java:147)〜[classes!/:1.0.1] 在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)〜[na:1.8.0_111] 在sun.reflect.NativeMethodAccessorImpl.invoke(未知来源)〜[na:1.8.0_111] 在sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源)〜[na:1.8.0_111] 在java.lang.reflect.Method.invoke(未知来源)〜[na:1.8.0_111] 在org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)〜[spring-web-4.3.3.RELEASE.jar!/:4.3.3.RELEASE] 在org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)〜[spring-web-4.3.3.RELEASE.jar!/:4.3.3.RELEASE] 在org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:114)〜[spring-webmvc-4.3.3.RELEASE.jar!/:4.3.3.RELEASE] 在org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)〜[spring-webmvc-4.3.3.RELEASE.jar!/:4.3.3.RELEASE] 在org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)〜[spring-webmvc-4.3.3.RELEASE.jar!/:4.3.3.RELEASE] 在org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)〜[spring-webmvc-4.3.3.RELEASE.jar!/:4.3.3.RELEASE] 在org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)〜[spring-webmvc-4.3.3.RELEASE.jar!/:4.3.3.RELEASE] 在org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)〜[spring-webmvc-4.3.3.RELEASE.jar!/:4.3.3.RELEASE] 在org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)〜[spring-webmvc-4.3.3.RELEASE.jar!/:4.3.3.RELEASE] 在org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:883)〜[spring-webmvc-4.3.3.RELEASE.jar!/:4.3.3.RELEASE] 在javax.servlet.http.HttpServlet.service(HttpServlet.java:710)〜[javax.servlet-api-3.1.0.jar!/:3.1.0] 在org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)〜[spring-webmvc-4.3.3.RELEASE.jar!/:4.3.3.RELEASE] 在javax.servlet.http.HttpServlet.service(HttpServlet.java:790)〜[javax.servlet-api-3.1.0.jar!/:3.1.0] 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)〜[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)〜[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)〜[tomcat-embed-websocket-8.5.5.jar!/:8.5.5] 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)〜[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)〜[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55)〜[spring-boot-1.4.1.RELEASE.jar!/:1.4.1.RELEASE] 在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)〜[spring-web-4.3.3.RELEASE.jar!/:4.3.3.RELEASE] 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)〜[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)〜[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在com.medlife.auth.MLAuthFilter.doFilter(MLAuthFilter.java:140)〜[ml-auth-filter-1.0.819.jar!/:na] 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)〜[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)〜[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:105)〜[spring-boot-actuator-1.4.1.RELEASE.jar!/:1.4.1.RELEASE] 在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)〜[spring-web-4.3.3.RELEASE.jar!/:4.3.3.RELEASE] 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)〜[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)〜[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)〜[spring-web-4.3.3.RELEASE.jar!/:4.3.3.RELEASE] 在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)〜[spring-web-4.3.3.RELEASE.jar!/:4.3.3.RELEASE] 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)〜[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)〜[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:89)〜[spring-web-4.3.3.RELEASE.jar!/:4.3.3.RELEASE] 在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)〜[spring-web-4.3.3.RELEASE.jar!/:4.3.3.RELEASE] 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)〜[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)〜[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)〜[spring-web-4.3.3.RELEASE.jar!/:4.3.3.RELEASE] 在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)〜[spring-web-4.3.3.RELEASE.jar!/:4.3.3.RELEASE] 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)〜[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)〜[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.springframework.cloud.sleuth.instrument.web.TraceFilter.doFilter(TraceFilter.java:141)〜[spring-cloud-sleuth-core-1.1.0.RELEASE.jar!/:1.1.0.RELEASE] 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)〜[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)〜[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)〜[spring-web-4.3.3.RELEASE.jar!/:4.3.3.RELEASE] 在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)〜[spring-web-4.3.3.RELEASE.jar!/:4.3.3.RELEASE] 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)〜[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)〜[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:107)〜[spring-boot-actuator-1.4.1.RELEASE.jar!/:1.4.1.RELEASE] 在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)〜[spring-web-4.3.3.RELEASE.jar!/:4.3.3.RELEASE] 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)〜[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)〜[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)〜[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)上[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784)[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)上[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.apache.coyote.AbstractProtocol $ ConnectionHandler.process(AbstractProtocol.java:802)[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun(NioEndpoint.java:1410)[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)上[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在java.util.concurrent.ThreadPoolExecutor.runWorker(未知来源)[na:1.8.0_111] 在java.util.concurrent.ThreadPoolExecutor $ Worker.run(未知来源)[na:1.8.0_111] 在org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61)[tomcat-embed-core-8.5.5.jar!/:8.5.5] 在java.lang.Thread.run(未知来源)[na:1.8.0_111]
对此有任何投入吗?
答案 0 :(得分:0)
您必须允许servlet配置
例如
public class WebAppInitializer implements WebApplicationInitializer{
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
ContextLoaderListener contextLoaderListener = new ContextLoaderListener(ctx);
servletContext.addListener(contextLoaderListener);
ctx.register(WebConfig.class);
ServletRegistration.Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
servlet.setLoadOnStartup(1);
servlet.addMapping("/");
servlet.setAsyncSupported(true); // For Allow Async Calls
servlet.setInitParameter("dispatchOptionsRequest", "true");
}
请检查您的配置