Search code examples
imagewindows-7jasper-reportstemporary-files

JasperReport creation with image fails to create temporary file on Windows Vista, 7 or Server 2008


We are getting the following error while generating a Jasper report when running our app on some machines with Windows Vista, Windows 7 or Windows 2008:

java.lang.RuntimeException: net.sf.jasperreports.engine.JRException: javax.imageio.IIOException: Can't create output stream! at br.com.oobj.relatorio.RRelatorioJasper.gerarJasperPrint(RRelatorioJasper.java:61) at br.com.oobj.relatorio.RRelatorioJasper.gerarJasperPrint(RRelatorioJasper.java:44) at br.com.oobj.cte.dacte.RGerarDacte.gerarJasperPrint(RGerarDacte.java:153) at br.com.oobj.cte.dacte.RGerarDacte.gerarJasperPrint(RGerarDacte.java:66) at br.com.oobj.me.impressao.GeradorDacte.gerarDAME(GeradorDacte.java:55) at br.com.oobj.me.impressao.GeradorDameDelegator.gerarDAME(GeradorDameDelegator.java:23) at br.com.oobj.me.impressao.ServicoImpressao.processar(ServicoImpressao.java:117) at br.com.oobj.me.impressao.ConsumidorImpressao.novaMensagem(ConsumidorImpressao.java:71) at br.com.oobj.util.fila.ConsumidorNotificante.run(ConsumidorNotificante.java:229) at br.com.oobj.me.impressao.ConsumidorImpressao.run(ConsumidorImpressao.java:47) Caused by: net.sf.jasperreports.engine.JRException: javax.imageio.IIOException: Can't create output stream! at net.sf.jasperreports.engine.util.JRJdk14ImageEncoder.encode(JRJdk14ImageEncoder.java:90) at net.sf.jasperreports.engine.util.JRAbstractImageEncoder.encode(JRAbstractImageEncoder.java:74) at net.sf.jasperreports.engine.util.JRImageLoader.loadImageDataFromAWTImage(JRImageLoader.java:166) at net.sf.jasperreports.engine.JRImageRenderer.getInstance(JRImageRenderer.java:207) at net.sf.jasperreports.engine.JRImageRenderer.getInstance(JRImageRenderer.java:190) at net.sf.jasperreports.engine.fill.JRFillImage.evaluateImage(JRFillImage.java:901) at net.sf.jasperreports.engine.fill.JRFillImage.evaluate(JRFillImage.java:870) at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:275) at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:426) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBandNoOverflow(JRVerticalFiller.java:424) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillPageHeader(JRVerticalFiller.java:388) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:249) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:113) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:891) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:814) at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:517) at br.com.oobj.relatorio.RRelatorioJasper.gerarJasperPrint(RRelatorioJasper.java:58) ... 9 more Caused by: javax.imageio.IIOException: Can't create output stream! at javax.imageio.ImageIO.write(Unknown Source) at net.sf.jasperreports.engine.util.JRJdk14ImageEncoder.encode(JRJdk14ImageEncoder.java:86) ... 27 more Caused by: javax.imageio.IIOException: Can't create cache file! at javax.imageio.ImageIO.createImageOutputStream(Unknown Source) ... 29 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(Unknown Source) at java.io.File.createTempFile(Unknown Source) at javax.imageio.stream.FileCacheImageOutputStream.(Unknown Source) at com.sun.imageio.spi.OutputStreamImageOutputStreamSpi.createOutputStreamInstance(Unknown Source) ... 30 more

The report references an external JPG image. The application runs as a windows service. I already tried to start the service with an administrator user, with no success.

In some machines, we solved the issue by relocating the image to a different drive other than C:

Will be very grateful with any help you can bring.

Thanks, Jonathas


Solution

  • It seems that Windows 2008 has different defaults for some system directives concerning services.

    While running the application in user mode (i.e. running from within a windows user session), the problem does not verify.

    Also, if we moved the file to a drive other than the drive on which windows is installed, the problem does not occur.

    It's not exactly a solution (I didn't figure out exactly what system directive to change), but I belive this information could eventually help.