0

ZK Jasper report - Display img tag HTML in jasper

asked 2022-11-04 20:43:29 +0800

softteam gravatar image softteam
130 1 8

Hello!

I'm using Jasperreport with ZK and I've run into a problem. I have generated my .jasper in which there is a hc:html tag for display html content, including an image:

image description

When processing the code to export a PDF I get the following error:

image description

The jasper file and the jrxml file are both generated with Jaspersoft, and processed in java as follows:

image description image description

Do you know how to solve this problem when exporting or how do you export the .jasper with img tags in html?

We are using the jasper reports jar version introduced with ZK version 9.6.3

Thank you!!

delete flag offensive retag edit

4 Answers

Sort by ยป oldest newest most voted
0

answered 2022-11-07 15:14:43 +0800

hawk gravatar image hawk
3250 1 5
http://hawkphoenix.blogsp... ZK Team

updated 2022-11-07 15:15:41 +0800

The error looks like a jasper report issue, not ZK. Could you post the complete message of ClassCastException? Since it's cut in your screenshot.

According to the code, the type of HtmlComponent.context is net.sf.masperreports.engine.component.BaseComponentContet. So the type is matched. I don't understand why a ClassCastException happens.

public HtmlComponent(HtmlComponent component, JRBaseObjectFactory objectFactory) {
    this.scaleType = component.getScaleType();
    this.horizontalImageAlign = component.getHorizontalImageAlign();
    this.verticalImageAlign = component.getVerticalImageAlign();
    this.htmlContentExpression = objectFactory.getExpression(component.getHtmlContentExpression());
    this.context = new BaseComponentContext(component.getContext(), objectFactory);
...
link publish delete flag offensive edit
0

answered 2022-11-07 19:24:10 +0800

softteam gravatar image softteam
130 1 8

Hi!

This is the complete message displayed by the console:

java.lang.ClassCastException: cannot assign instance of net.sf.jasperreports.engine.component.BaseComponentContext to field net.sf.jasperreports.components.html.HtmlComponent.context of type net.sf.jasperreports.engine.component.ComponentContext in instance of net.sf.jasperreports.components.html.HtmlComponent

link publish delete flag offensive edit
0

answered 2022-11-15 18:41:09 +0800

softteam gravatar image softteam
130 1 8

Hi, any ideas?

Thank you!

link publish delete flag offensive edit
0

answered 2022-11-24 13:22:46 +0800

hawk gravatar image hawk
3250 1 5
http://hawkphoenix.blogsp... ZK Team

According to the stack trace, it throws classcastexception while deserializing net.sf.jasperreports.components.html.HtmlComponent.

this could be caused by many reasons, for example:

  1. different serialize version uid
  2. deserialize from a different VM/classloader

It's hard to locate the root cause with the current information. You can try to investigate in deserializing issue.

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2022-11-04 20:43:29 +0800

Seen: 15 times

Last updated: Nov 24 '22

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More