java.lang.IllegalArgumentException: ServletContext must not be null

系统刚刚整合了redis,实现集群下 session共享, 今天突然发现上传模块出现 无法获取servletcontext的问题,错误如下


07-Jan-2019 15:55:06.106 SEVERE [http-nio-7777-exec-9] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [insurance_web_servlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalArgumentException: ServletContext must not be null] with root cause
 java.lang.IllegalArgumentException: ServletContext must not be null
        at org.springframework.util.Assert.notNull(Assert.java:112)
        at org.springframework.web.util.WebUtils.getTempDir(WebUtils.java:212)
        at org.springframework.web.multipart.commons.CommonsMultipartResolver.setServletContext(CommonsMultipartResolver.java:117)
        at org.springframework.web.multipart.commons.CommonsMultipartResolver.<init>(CommonsMultipartResolver.java:87)
        at com.jufengad.insurance.api.global.file.DoUploadFile.upload(DoUploadFile.java:45)
        at com.jufengad.insurance.web.controller.file.UploadController.rateFileUpload(UploadController.java:108)
        at com.jufengad.insurance.web.controller.file.UploadController$$FastClassBySpringCGLIB$$8dd8eb86.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:711)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
        at org.apache.shiro.spring.security.interceptor.AopAllianceAnnotationsAuthorizingMethodInterceptor$1.proceed(AopAllianceAnnotationsAuthorizingMethodInterceptor.java:82)

之前获取上下文时,是通过httprequest session获取, 当session存储在redis时,获取上下文失败

request.getSession().getServletContext()

直接从request里获取就好,不用再从session里获取,

request.getServletContext()
发布了59 篇原创文章 · 获赞 11 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/zhangjianming2018/article/details/86009358