原来中间件的temp目录也有大作用

最近,小编在使用jcaptcha 来生成验证码时,无意间发现个问题~多方谷歌、度娘后,方知答案!!

参阅:http://blog.sina.com.cn/s/blog_5999840701009t06.html

 

 

一直用eclipse-jetty 插件在运行,没发现生成用jcaptcha验证码对temp目录的作用,直到部署到tomcat上是,无意间把tomcat-temp目录删除后,程序报

javax.imageio.IIOException: Can't create output stream!
	at javax.imageio.ImageIO.write(ImageIO.java:1560)
	at com.csair.cas.web.servlet.ImageCaptchaServlet.generateCaptchaImage(ImageCaptchaServlet.java:58)
	at com.csair.cas.web.servlet.ImageCaptchaServlet.doGet(ImageCaptchaServlet.java:31)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.github.inspektr.common.web.ClientInfoThreadLocalFilter.doFilter(ClientInfoThreadLocalFilter.java:63)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
	at java.lang.Thread.run(Thread.java:662)
Caused by: javax.imageio.IIOException: Can't create cache file!
	at javax.imageio.ImageIO.createImageOutputStream(ImageIO.java:397)
	at javax.imageio.ImageIO.write(ImageIO.java:1558)
	... 25 more
Caused by: java.io.IOException: 系统找不到指定的路径。
	at java.io.WinNTFileSystem.createFileExclusively(Native Method)
	at java.io.File.checkAndCreate(File.java:1704)
	at java.io.File.createTempFile(File.java:1792)
	at javax.imageio.stream.FileCacheImageOutputStream.<init>(FileCacheImageOutputStream.java:71)
	at com.sun.imageio.spi.OutputStreamImageOutputStreamSpi.createOutputStreamInstance(OutputStreamImageOutputStreamSpi.java:50)
	at javax.imageio.ImageIO.createImageOutputStream(ImageIO.java:393)
	... 26 more

 

 

在调用jcaptcha的servlet里,这个方法

ImageIO.write(image, "jpeg", response.getOutputStream());

需要写缓存文件....估计使用jcaptcha 生产验证码时需要用到temp目录,但是却又不往里写数据...奇怪吧~~

 

吸取教训~~原来每个中间件的temp目录是有可能有作用~~切记勿删除哈~~~

 

 

 

你可能感兴趣的:(中间件)