Failing to load images (Byte data not found)


I have a couple images in a report and when I run it the following exception occurs:

net.sf.jasperreports.engine.JRException: Byte data not found at location : header-slice-wide.JPG
at net.sf.jasperreports.engine.util.JRLoader.loadBytesFromLocation(
at net.sf.jasperreports.engine.JRImageRenderer.getInstance(
at net.sf.jasperreports.engine.fill.JRFillImage.evaluateImage(

I've set the SUBREPORT_DIR parameter before running the report but this has not fixed the problem. How are embedded images handled?


jbaker's picture
Joined: Jan 19 2007 - 2:43am
Last seen: 14 years 2 months ago

5 Answers:

The best way is to use iReport and the jasperserver plugin ...
Then, any image you drag&drop from the JS plugin view onto the report is reference by a repo:... url, which is then used for finding the image when running the report on the server.
Of course, this requires the image to be on the server - which it does, anyway, if you want to use it from JasperServer.
On the other hand, a repo: URL can't be accessed when you just run the report in iReport, only when running it via the plugin.

csbac's picture
Joined: Mar 12 2007 - 7:42pm
Last seen: 14 years 1 month ago

I've looked into this problem and concluded that images handling requires some work. The current implementation attempts to create a File object with the image name, which assumes the image resides in the current working directory:

JRLoader. public static Object loadObjectFromLocation(
String location,
ClassLoader classLoader,
URLStreamHandlerFactory urlHandlerFactory
) throws JRException

// Cut

File file = new File(location);
if (file.exists() && file.isFile())

This isn't really a very useful solution for a web based environment. I've worked around the problem by writing my own renderer that has a static directory in which images will be found, however this is also over kill.

The solution is for the default image loader (from files) to make use of a parameter that can be passed into the report. Very much like the subreport parameter, this parameter would state where the images have been stored.

I take your point concerning jasper server but the company I am working for wanted their own version, and to be honest, we should probably open source it as it's rather smart!

Is there any chance the image directory parameter could be added in a future release?


jmbaker's picture
Joined: Mar 7 2007 - 12:29am
Last seen: 14 years 1 month ago
You can manually create an image directory parameter and use it the source expression of each image.

Also, if you look at the entire loadObjectFromLocation method you will see that it also attempts to resolve the location as a URL or a classloader resource. Therefore, you can customize the way images are loaded by providing URL handlers or custom classloaders.

If you have concrete improvement suggestions, please log them as [url= requests.

lucianc's picture
Joined: Jul 17 2006 - 1:10am
Last seen: 3 weeks 1 day ago

comment out the parameters in sub report jrxmls which are trying to get the chart info from another servers and and compile the jrxml again. Then execute .jasper .

balukondamuri's picture
Joined: Jul 15 2015 - 11:27am
Last seen: 5 years 9 months ago
Error 500: org.springframework.web.util.NestedServletException: Request processing failed; nested exception is net.sf.jasperreports.engine.JRException: Byte data not found at : ..//reports//images//xyz.gif
The above error is fixed by using the imageExpression
satishmhiremath's picture
Joined: Sep 29 2016 - 7:06am
Last seen: 3 years 6 months ago