Jump to content
We've recently updated our Privacy Statement, available here ×

JRException: Image failed to load


Recommended Posts

By: slowfinger - slowfinger

JRException: Image failed to load

2006-03-15 04:21

Hi,

 

I had curious behaviour with some images on my report. Now I have found the reason for the exception above:

 

The problem image was one which was used on the page header. So on an report which has more than one page the error occurs every time if I move from the first page to one of the next one's.

 

The search for the error was difficult but the solution was easy. I set the flag isUsingCache to true and all works fine.

 

Now I'm considering if that is the correct behaviour. What is your opinion ?

 

Thanks in forward

Rico

 

PS: Oh I think this an error which is really risky. Because the mentioned error occured so on the JasperViewer. But when I produced an PDF it ends with an NullPointerException and that can't be in sence of the inventor.

 

 

By: Code_Slave - code_slave

RE: JRException: Image failed to load

2006-03-15 17:38

do not try to put the actual image into the hash map

 

private void Getpictures(HashMap ReportParams) {

java.net.URL Source;

java.net.URL Source1;

 

Source = MyProvidesReports.class.getResource("/Images/Image1.png"); // this is a fixed format for all java platforms do not use "file.separator

Source1 = MyProvidesReports.class.getResource("/Images/Chop.png"); // this is a fixed format for all java platforms do not use "file.separator

 

ReportParams.put("MyChop", Source1);

ReportParams.put("CompanyLogo", Source);

}

instead of passing an actual image, pass a pointer to it's path, let JR deal with getting & releasing it, or you will end up with memory leaks.

 

 

 

 

By: slowfinger - slowfinger

RE: JRException: Image failed to load

2006-03-15 22:22

I do not understand your answer. Your suggestion is not to put the image on the map but your sample code does it.

 

Also I don't see a different way in my case because it plays in a web environment. The image are in the class path and will be loaded by:

stream = getClass().getClassLoader().getResourceAsStream(image));

and put on the map:

 

parameter.put(REPORT_LOGO, stream);

 

 

 

 

By: slowfinger - slowfinger

RE: JRException: Image failed to load

2006-03-15 04:24

oh I forgot following. I put the described image as parameter as InputStream to the parameter map.

 

 

By: Krishna - krishnamurthir

RE: JRException: Image failed to load

2006-07-30 10:49

Dear Friend,

 

we can pass the img directly to the .jrxml file

 

the ex.

 

in the img Expression (.jrxml)

getClass().getClassLoader().getResourceAsStream(com/../logo.jpg")]

 

class=java.io.InputStream

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...