participate


Java 2D - png export problem with ServletOutputStream but works with FileOutputStream
<<   Back to Forum  |   Give us Feedback
This topic has 6 replies on 1 page.
nathaniel_auvil
Posts:3
Registered: 2/26/99
png export problem with ServletOutputStream but works with FileOutputStream   
Feb 25, 2002 7:01 PM

 
ImageIO method write() takes an OutputStream so I am confused as to why i can
write out a png to a FileOutputStream but not a ServletOutputStream.
Any ideas? And why is there a call to create a 'cache file' by the
ImageIO class? This would be a huge performance problem.


I am using Tomcat 4.0.2



javax.imageio.IIOException: Can't create output stream!
at javax.imageio.ImageIO.write(ImageIO.java:1436)
at org.jCharts.encoders.PNGEncoder.encode(Unknown Source)
at org.jCharts.demo.servletsApp.BarChartServlet.service(Unknown
Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:446)
at org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:180)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1012)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107)
at java.lang.Thread.run(Thread.java:536)
Caused by: javax.imageio.IIOException: Can't create cache file!
at javax.imageio.ImageIO.createImageOutputStream(ImageIO.java:328)
at javax.imageio.ImageIO.write(ImageIO.java:1434)
... 37 more
Caused by: java.io.IOException: The system cannot find the path
specified
at java.io.WinNTFileSystem.createFileExclusively(Native
Method)
at java.io.File.checkAndCreate(File.java:1294)
at java.io.File.createTempFile(File.java:1382)
at javax.imageio.stream.FileCacheImageOutputStream.<init>(FileCacheImageOutputStream.java:66)
at com.sun.imageio.spi.OutputStreamImageOutputStreamSpi.createOutputStreamInstance(OutputStreamImageOutputStreamSpi.java:50)
at javax.imageio.ImageIO.createImageOutputStream(ImageIO.java:324)
... 38 more
 
nathaniel_auvil
Posts:3
Registered: 2/26/99
Re: png export problem with ServletOutputStream but works with FileOutputStream   
Feb 26, 2002 10:47 AM (reply 1 of 6)  (In reply to original post )

 
the problem here is i needed to use the setUseCache( boolean ) and set it to false.

When i used a FileOutputStream, i guess it bypasses the cache as you are already using a file. extra overhead in casting to see if it is a FileOutputStream though.

Why on earth would the default be 'true'?
 
pmizgalewicz
Posts:1
Registered: 6/26/00
Re: png export problem with ServletOutputStream but works with FileOutputStream   
Apr 12, 2002 5:55 AM (reply 2 of 6)  (In reply to original post )

 
I think the problem is with the "tmp" directory.
When I installed CATALINA (on UNIX) it did not create tmp folder. However, the statrup script sets the CATALINA_TMP to $CATALINA/tmp. I was not able to use cache, OutputStreams, and other classes which cache to disk, until I created temp folder. Now it works fine.

Create the "tmp" folder, check all your env variables (such as JAVA_HOME, CATALINA_HOME, and few others) and see if you have the same errors.
 
delewis
Posts:29
Registered: 1/23/02
Re: png export problem with ServletOutputStream but works with FileOutputStream   
Jun 21, 2002 9:29 AM (reply 3 of 6)  (In reply to #2 )

 
Thanks for your help! I was experiencing the same "Can't create cache file" problem when using ImageIO.read() in a servlet context on Solaris UNIX. When running locally (using Tomcat) on a Win2K system, there were no problems. It seems that with the Win2K installation, the "temp" directory is automatically made. With the Solaris installation, the "temp" is not made! Simply adding the directory cured the caching problems.
 
bkhendershot
Posts:48
Registered: 5/29/02
Re: png export problem with ServletOutputStream but works with FileOutputStream   
Sep 18, 2002 1:24 PM (reply 4 of 6)  (In reply to #3 )

 
Maybe one of you can help me... I have an applet/servlet pair using ImageI/O to save a buffered image as a PNG file. I downloaded Tomcat 4.0.3 to act as a servlet container so I could test my program on my local machine running Windows ME and JDK 1.4. Everything worked fine. I then got a webhost which uses JDK 1.4 and Tomcat 4.0.1 on a Unix server. Now I'm getting errors on the ImageI/O commands and the program just stops running when it gets to them. The errors in the web-log are:

File does not exist: /home/foico/html/META-INF/services/javax.imageio.spi.ImageTranscoderSpi
File does not exist: /home/foico/html/META-INF/services/javax.imageio.spi.ImageWriterSpi
...

I get 5 different errors (ImageTranscoderSpi, ImageWriterSpi, ImageReaderSpi, ImageOutputStreamSpi, ImageInputStreamSpi).

I've tried putting everything into a JAR file and I created a META-INF/services folder with the files it's looking for. Inside the files I listed the Service Providers I found shipped with my JVM. But now in the Java Console, I get these types of errors:

sun.misc.ServiceConfigurationError: javax.imageio.spi.ImageInputStreamSpi: jar:http://www.imaginacard.com/IDraw.jar!/META-INF/services/javax.imageio.spi.ImageInputStreamSpi:1: Illegal provider-class name: com.sun.imageio.spi.RAFImageInputStreamSpi@f1fba0

I have searched and searched for over a week and cannot seem to find much documentation on this. I've read all through the ImageIO, ImageIO.SPI documentation and I've tried everything I can think of. Since you seemed to be doing some ImageI/O online, I wondered if you ran into any problems with it similar to mine or if you know of what I could do differently.

Any suggestions will be greatly appreciated.

Thanks.
 
gurnard
Posts:13
Registered: 5/24/04
Re: png export problem with ServletOutputStream but works with FileOutputSt   
Mar 17, 2005 3:09 AM (reply 5 of 6)  (In reply to #4 )

 
I have the same problem with the ImageIO did anyone ever resolve this?

cheers
Martin
 
avileno
Posts:1
Registered: 7/26/07
Re: png export problem with ServletOutputStream but works with FileOutputSt   
Jul 26, 2007 1:17 PM (reply 6 of 6)  (In reply to #5 )

 
thank you. Realy the problem was the "temp" folder
 
This topic has 6 replies on 1 page.
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics
    Users Online : 28
  • Guests : 133

About Sun forums
  • Oracle Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Oracle Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums