본문 바로가기

밥벌이1 - S/W/Java

[Java] Imageio Can't create cache file! at tomcat


Default javax.imageio.IIOException: Can't create cache file!

Dear All,

Some Tomcat installations do not have their temp folder created. Tomcat will not create that folder for you, so check that it exists when you start Tomcat.

When Tomcat starts, it lets you know what it thinks it temp folder should be, as shown below:
Code:
Using CATALINA_BASE:   /Users/kjkoster/workspace/todo/apache-tomcat-5.5.17
Using CATALINA_HOME:   /Users/kjkoster/workspace/todo/apache-tomcat-5.5.17
Using CATALINA_TMPDIR: /Users/kjkoster/workspace/todo/apache-tomcat-5.5.17/temp
Using JRE_HOME:       /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
All you have to do is check that the directory ${CATALINA_TMPDIR} exists and is writable for the user that Tomcat runs as. If you don't, you may get some bizarre errors when Java needs to create temporary items.

Code:
javax.imageio.IIOException: Can't create output stream!
	javax.imageio.ImageIO.write(Unknown Source)
	Presentation.Captcha.doGet(Captcha.java:66)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause

javax.imageio.IIOException: Can't create cache file!
	javax.imageio.ImageIO.createImageOutputStream(Unknown Source)
	javax.imageio.ImageIO.write(Unknown Source)
	Presentation.Captcha.doGet(Captcha.java:66)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause

java.io.IOException: No such file or directory
	java.io.UnixFileSystem.createFileExclusively(Native Method)
	java.io.File.checkAndCreate(Unknown Source)
	java.io.File.createTempFile(Unknown Source)
	javax.imageio.stream.FileCacheImageOutputStream.<init>(Unknown Source)
	com.sun.imageio.spi.OutputStreamImageOutputStreamSpi.createOutputStreamInstance(Unknown Source)
	javax.imageio.ImageIO.createImageOutputStream(Unknown Source)
	javax.imageio.ImageIO.write(Unknown Source)
	com.example.MyServlet.doGet(MyServlet.java:66)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)