错误信息:
2019-01-18 10:58:32.094 ERROR 11113 --- [nio-8086-exec-9] o.a.c.c.C.[.[.[.[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [/energymanagement] threw exception [Request processing failed; nested exception is org.springframework.web.socket.sockjs.SockJsException: Uncaught failure in SockJS request, uri=http://192.168.168.180:8086/xxxxx/socket/690/a4o3vo4b/xhr?t=1547780328164; nested exception is org.springframework.web.socket.sockjs.SockJsTransportFailureException: Failed to open session; nested exception is java.lang.IllegalArgumentException: Async support must be enabled on a servlet and for all filters involved in async request processing. This is done in Java code using the Servlet API or by adding "<async-supported>true</async-supported>" to servlet and filter declarations in web.xml. Also you must use a Servlet 3.0+ container] with root cause
java.lang.IllegalArgumentException: Async support must be enabled on a servlet and for all filters involved in async request processing. This is done in Java code using the Servlet API or by adding "<async-supported>true</async-supported>" to servlet and filter declarations in web.xml. Also you must use a Servlet 3.0+ container
....//省略其他异常信息
at com.xxxxxx.energymanagement.CrossFilter.doFilter(CrossFilter.java:37) ~[classes!/:0.0.1-SNAPSHOT]
.....//省略其他异常信息
错误中,只有这一句是关于项目中文件,而且是一个Fileter。
错误原因:
具体原因不清楚,可以参考https://www.cnblogs.com/guangshan/p/4916993.html该博主的分享
错误解决:
在项目中的所有Filter中的@WebFilter中增加异步支持asyncSupported=true
EG:@WebFilter(filterName = "CrossFilter", urlPatterns = "/*",asyncSupported=true)
同时在项目的启动类增加@EnableAsync注解。经测试,此方法可以解决该异常。