Failing to load images (Byte data not found)

0
Hello,

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(JRLoader.java:467)
at net.sf.jasperreports.engine.JRImageRenderer.getInstance(JRImageRenderer.java:175)
at net.sf.jasperreports.engine.fill.JRFillImage.evaluateImage(JRFillImage.java:477)

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

Thanks,


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

5 Answers:

0
Hi!
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.

Sebastian
csbac's picture
130
Joined: Mar 12 2007 - 7:42pm
Last seen: 12 years 1 week ago
0
Hi,

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())
{
return

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?

Thanks,


John
jmbaker's picture
27
Joined: Mar 7 2007 - 12:29am
Last seen: 12 years 2 weeks ago
0
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=http://www.jasperforge.org/sf/tracker/do/listArtifacts/projects.jasperre... requests.

Regards,
Lucian
lucianc's picture
7045
Joined: Jul 17 2006 - 1:10am
Last seen: 3 days 10 hours ago
0

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: 3 years 8 months ago
0
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
 
getClass().getResource("META-INF/resources/......../themes/default/images/xyz.png").openStream()
satishmhiremath's picture
Joined: Sep 29 2016 - 7:06am
Last seen: 1 year 6 months ago
Feedback
randomness