项目上线正常运行一段时间后,有一天突然所有的附件上传都出现了错误,查找项目本身的日志系统也一致没有跟踪到错误。经过几番折腾,在tomcat9-stdout.log日志中发现如下异常:
ERROR org.springframework.boot.web.servlet.support.ErrorPageFilter 190 forwardToErrorPage - Forwarding to error page from request [/upload/dbupload] due to exception [Failed to parse multipart servlet request; nested exception is java.io.IOException: org.apache.tomcat.util.http.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. E:\Tomcat9\work\Catalina\localhost\ROOT\upload_6aee88fc_f7bb_4c8d_b663_51fad2d80eee_00000000.tmp (文件或目录损坏且无法读取。)] org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is java.io.IOException: org.apache.tomcat.util.http.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. E:\Tomcat9\work\Catalina\localhost\ROOT\upload_6aee88fc_f7bb_4c8d_b663_51fad2d80eee_00000000.tmp (文件或目录损坏且无法读取。)
因此,可能是无法访问tomcat工作目录work所致。
因此将此work目录重命名为_work,并重启服务器后,重建工作目录work,恢复正常。