解决tomcat报错javax.imageio.IIOException: Can't create output stream!
启动tomcat catalina.out报错如下,登陆的时候无法显示验证码
2017-06-09 11:23:06,628 DEBUG org.springframework.web.servlet.DispatcherServlet 845 - DispatcherServlet with name 'spring-mvc' processing GET request for [/data-analysis/kaptchaImage.do]
2017-06-09 11:23:06,629 DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping 297 - Looking up handler method for path /kaptchaImage.do
2017-06-09 11:23:06,629 DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping 302 - Returning handler method [public org.springframework.web.servlet.ModelAndView com.chinasoft.web.dataanalysis.business.sys.controller.LoginController.getKaptchaImage(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.lang.Exception]
2017-06-09 11:23:06,630 DEBUG o.s.b.factory.support.DefaultListableBeanFactory 248 - Returning cached instance of singleton bean 'loginController'
2017-06-09 11:23:06,630 DEBUG org.springframework.web.servlet.DispatcherServlet 931 - Last-Modified value for [/data-analysis/kaptchaImage.do] is: -1
2017-06-09 11:23:06,773 DEBUG o.s.w.s.m.m.a.ExceptionHandlerExceptionResolver 134 - Resolving exception from handler [public org.springframework.web.servlet.ModelAndView com.chinasoft.web.dataanalysis.business.sys.controller.LoginController.getKaptchaImage(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.lang.Exception]: javax.imageio.IIOException: Can't create output stream!
2017-06-09 11:23:06,775 DEBUG o.s.w.s.m.a.ResponseStatusExceptionResolver 134 - Resolving exception from handler [public org.springframework.web.servlet.ModelAndView com.chinasoft.web.dataanalysis.business.sys.controller.LoginController.getKaptchaImage(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.lang.Exception]: javax.imageio.IIOException: Can't create output stream!
2017-06-09 11:23:06,776 DEBUG o.s.w.s.m.support.DefaultHandlerExceptionResolver 134 - Resolving exception from handler [public org.springframework.web.servlet.ModelAndView com.chinasoft.web.dataanalysis.business.sys.controller.LoginController.getKaptchaImage(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.lang.Exception]: javax.imageio.IIOException: Can't create output stream!
2017-06-09 11:23:06,777 DEBUG o.s.w.s.handler.SimpleMappingExceptionResolver 134 - Resolving exception from handler [public org.springframework.web.servlet.ModelAndView com.chinasoft.web.dataanalysis.business.sys.controller.LoginController.getKaptchaImage(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.lang.Exception]: javax.imageio.IIOException: Can't create output stream!
2017-06-09 11:23:06,777 DEBUG o.s.w.s.handler.SimpleMappingExceptionResolver 249 - Resolving to view 'exception' for exception of type [javax.imageio.IIOException], based on exception mapping [java.lang.Exception]
2017-06-09 11:23:06,777 DEBUG o.s.w.s.handler.SimpleMappingExceptionResolver 341 - Exposing Exception as model attribute 'exception'
2017-06-09 11:23:06,785 DEBUG org.springframework.web.servlet.DispatcherServlet 1182 - Handler execution resulted in exception - forwarding to resolved error view: ModelAndView: reference to view with name 'exception'; model is {exception=javax.imageio.IIOException: Can't create output stream!}
javax.imageio.IIOException: Can't create output stream!
at javax.imageio.ImageIO.write(ImageIO.java:1574) ~[na:1.8.0_102]
at com.chinasoft.web.dataanalysis.business.sys.controller.LoginController.getKaptchaImage(LoginController.java:204) ~[LoginController.class:na]
at com.chinasoft.web.dataanalysis.business.sys.controller.LoginController$$FastClassBySpringCGLIB$$21c731f2.invoke(<generated>) ~[spring-core-4.1.4.RELEASE.jar:na]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:649) ~[spring-aop-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at com.chinasoft.web.dataanalysis.business.sys.controller.LoginController$$EnhancerBySpringCGLIB$$f3f26f78.getKaptchaImage(<generated>) ~[spring-core-4.1.4.RELEASE.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_102]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_102]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_102]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_102]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) ~[spring-web-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137) ~[spring-web-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) ~[spring-webmvc-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:777) ~[spring-webmvc-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:706) ~[spring-webmvc-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943) [spring-webmvc-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) [spring-webmvc-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) [spring-webmvc-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857) [spring-webmvc-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:620) [servlet-api.jar:na]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) [spring-webmvc-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) [servlet-api.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) [catalina.jar:7.0.54]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.54]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat7-websocket.jar:7.0.54]
后面搜索了一下,原来是根目录缺少temp这个目录导致的,之前清理缓存的时候不小心删除了这个目录
新建这个目录,重启tomcat即可