JasperReport: Image parameter problem on Win 7 64

We have a couple of clients running Windows 7 64 bit application server. Reports that are working with other installations (including other Windows 7 64 bit) are failing on these installs, because of some permission problem. We pass some parameters containing the images for the header and footer to the report. When we remove the images (nothing is passed to the report), the report works fine. We know the header and footer images are fine, since they work with all other installs and the same reports. The Java console output shows the following error details:

ERROR - Debug                      - Throwable
net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression : 
	Source text : net.sf.jasperreports.engine.util.JRImageLoader.loadImage((byte[])$P{pHeader})
	at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:193)
	at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:570)
	at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:538)
	at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:868)
	at net.sf.jasperreports.engine.fill.JRFillImage.evaluateImage(JRFillImage.java:910)
	at net.sf.jasperreports.engine.fill.JRFillImage.evaluate(JRFillImage.java:891)
	at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:256)
	at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:482)
	at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillTitle(JRVerticalFiller.java:308)
	at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:244)
	at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:110)
	at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:923)
	at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:826)
	at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:59)
	at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:417)
	at com.servoy.plugins.jasperreports.JasperReportRunner.getJasperPrint(JasperReportRunner.java:244)
	at com.servoy.plugins.jasperreports.JasperReportsServer.getJasperPrint(JasperReportsServer.java:214)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
	at sun.rmi.transport.Transport$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.Transport.serviceCall(Unknown Source)
	at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
	at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
	at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
	at sun.rmi.server.UnicastRef.invoke(Unknown Source)
	at com.servoy.plugins.jasperreports.JasperReportsServer_Stub.getJasperPrint(Unknown Source)
	at com.servoy.plugins.jasperreports.JasperReportsProvider.runReport(JasperReportsProvider.java:369)
	at com.servoy.plugins.jasperreports.JasperReportsProvider.js_runReport(JasperReportsProvider.java:290)
	at com.servoy.plugins.jasperreports.JasperReportsProvider.js_jasperReport(JasperReportsProvider.java:274)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:179)
	at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:353)
	at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:81)
	at org.mozilla.javascript.gen.c173._c0(runOneReport:509)
	at org.mozilla.javascript.gen.c173.call(runOneReport)
	at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:387)
	at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3127)
	at org.mozilla.javascript.gen.c173.call(runOneReport)
	at com.servoy.j2db.scripting.Ztb.executeFunction(Ztb.java:196)
	at com.servoy.j2db.Zwb.Za(Zwb.java:741)
	at com.servoy.j2db.Zwb.Za(Zwb.java:1223)
	at com.servoy.j2db.Zwb.Za(Zwb.java:644)
	at com.servoy.j2db.plugins.ClientPluginAccessProvider$MethodExecutor.run(ClientPluginAccessProvider.java:37)
	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: net.sf.jasperreports.engine.JRException: javax.imageio.IIOException: Can't create cache file!
	at net.sf.jasperreports.engine.util.JRJdk14ImageReader.readImage(JRJdk14ImageReader.java:58)
	at net.sf.jasperreports.engine.util.JRImageLoader.loadImage(JRImageLoader.java:245)
	at Projects324532Master32Checklists_1268332368510_226654.evaluate(Projects324532Master32Checklists_1268332368510_226654:203)
	at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:182)
	at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:570)
	at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:538)
	at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:868)
	at net.sf.jasperreports.engine.fill.JRFillImage.evaluateImage(JRFillImage.java:910)
	at net.sf.jasperreports.engine.fill.JRFillImage.evaluate(JRFillImage.java:891)
	at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:256)
	at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:482)
	at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillTitle(JRVerticalFiller.java:308)
	at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:244)
	at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:110)
	at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:923)
	at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:826)
	at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:59)
	at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:417)
	at com.servoy.plugins.jasperreports.JasperReportRunner.getJasperPrint(JasperReportRunner.java:244)
	at com.servoy.plugins.jasperreports.JasperReportsServer.getJasperPrint(JasperReportsServer.java:214)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
	at sun.rmi.transport.Transport$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.Transport.serviceCall(Unknown Source)
	at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: javax.imageio.IIOException: Can't create cache file!
	at javax.imageio.ImageIO.createImageInputStream(Unknown Source)
	at javax.imageio.ImageIO.read(Unknown Source)
	at net.sf.jasperreports.engine.util.JRJdk14ImageReader.readImage(JRJdk14ImageReader.java:54)
	... 33 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.FileCacheImageInputStream.<init>(Unknown Source)
	at com.sun.imageio.spi.InputStreamImageInputStreamSpi.createInputStreamInstance(Unknown Source)
	... 36 more

It would appear that the images are being written as a temp file somewhere, that Jasper is then attempting to read, without success. Any ideas on where the cache file is supposed to be created?

Really, no ideas, not even from the Servoy team?

From the stackTrace, this seems to be the source of all the rest of the exceptions:
Caused by: java.io.IOException: The system cannot find the path specified

I would guess that Jasper is trying to create a cache file but can’t because it cannot find the right path to create it.
My guess would be that the file structure being different with Windows 7 than what it was with XP for example, the cache path is not found (for example C:\Documents and Settings\ being now C:\Users), that might also be related to enhance security with 7 that was not present, and maybe Jasper or the plugin is not taking that into account.

Apart from that I cannot offer any workaround, one would have to dig into the plugin source or the jasper lib sources to see where it breaks in this case.

Thanks for the insight Patrick. It is a puzzle, because as I mentioned, it works for most Win 7 64 bit setups, so using “c:\users” is not a problem. What is the specific cache folder that it would be trying to create or use? I cannot seem to identify that on either a working on non-working Win 7 installation. Would it be going into an AppData folder or Temp folder in the user’s directory? Researching the topic on the web, I found mention of a similar problem online (missing temp directory), which was solved by simply creating the directory manually, so it could be used.

I would definitely try creating the temp folder manually as a workaround.
If the post you talk about tells you where jasper is creating its cache file, try that!

It does not say where Jasper is creating the temp file, or what temp folder it is using. I guess this is the question, does anyone know?

Here is the link I found on this issue. Does this help us?

Try adding this line somewhere:

application.output(java.lang.System.getProperty("java.io.tmpdir"));

and see where it points to.
This is the temp folder that seems to be used by JAI, if it doesn’t exist or have security restriction, fix that manually, and this should work.

If it doesn’t, chek that you don’t have a CATALINA_BASE environment variable, and see where it points to, because $CATALINA_BASE/temp will be the place used by Tomcat for the JAI cache folder.

are you running that server as a service?
If so do you use local system account or something like that?

I think there is something weird because you are writing in a temp file location, and java gets that from the Operating system so it expects that it can write there.

I think what you can do is use different credentials for the servoy service, so really use a user that can logon.

This has nothing to do with the Tomcat portion. Because this is pure java that shouldn’t know that it is inside a servlet container (and that it could use the servlet containers temp folder which is server\work )
So it really uses java.io.tmpdir yes. that one is the right one that one should be writeable…

Yes, it is running as a service, and by default uses the Local System Account. I did try changing the service properties to run using an Administrator account, but then the service refused to start. I will try again.