PDA

View Full Version : Pentaho does display chart in an web application



max.sheng
11-14-2013, 06:24 AM
I embed the report in my web application. without the chart, the report is displaying properly, but if i put a chart , then error message will occur . I try pie chart and bar chart , got same error. I have include all needed jar file into my application, such as libbase.jar, jfreechart.jar,pentaho-reporting-engine-classic-core.jar,pentaho-reporting-engine-legacy-charts.jar...
the error message like:
----------------------
org.pentaho.reporting.libraries.xmlns.parser.ParseException: Expression 'org.pentaho.plugin.jfreereport.reportcharts.BarChartExpression' is not valid. [Location: Line=22 Column=190]
at org.pentaho.reporting.engine.classic.core.modules.parser.bundle.layout.elements.AttributeExpressionReadHandler.startParsing(AttributeExpressionReadHandler.java:96)
---------------------

I open the layout.xml file, the 22th line is :
-------------
<attribute-expression namespace="http://reporting.pentaho.org/namespaces/engine/attributes/core" name="value" class="org.pentaho.plugin.jfreereport.reportcharts.BarChartExpression">
-------------

further, I open the source code of AttributeExpressionReadHandler.java. the related code is pasted at follow:
-------------
if (expression == null && expressionClassName != null)
{


expression = (Expression) ObjectUtilities.loadAndInstantiate(expressionClassName, getClass(), Expression.class);
if (expression == null)
{
throw new ParseException("Expression '" + expressionClassName +
"' is not valid.", getLocator());
}
}
--------
I suspect that ObjectUtilities.loadAndInstantiate function return a null, but why it reurn null ? the reason I can't find out. Anybody can help me? I am very appreciate for see your responseļ¼

Taqua
11-14-2013, 07:11 AM
It returns null, if your classpath does NOT have all jars on it.

Ensure that both "legacy-charts", "jfreechart" and "jcommon" are on your classpath (and in the correct version, same as you can find in your PRD installation, for instance).

If you want to test it quickly, write yourself a unittest that just calls

Class.forName ("org.pentaho.plugin.jfreereport.reportcharts.BarChartExpression")

If that succeeds, then your classpath is fine. If not, then at least you know that there is no other error other than an invalid classpath.

max.sheng
11-14-2013, 08:54 PM
Thank you very much, Taqua . Yes, you are right! I wrote that unit test, then found it need another jar: bsf-2.4.0.jar,
so I added this dependency to my pom.xml. running my application , now there is none error , and the html report page can display , but none chart picture.
that position should be bar chart is blank. the pdf format report is correct , the chart picture is right.
I think this is my appliction's problem and the pentaho report is well all right. Thank you again!

max.sheng
11-14-2013, 09:38 PM
my code is:

response.setContentType("text/html;charset=UTF-8");
HtmlReportUtil.createStreamHTML(report, response.getOutputStream());

may be I should use createDirectoryHTML(JFreeReport (http://www.docjar.com/docs/api/org/jfree/report/JFreeReport.html) report,String (http://www.docjar.com/docs/api/java/lang/String.html) targetFileName) function instead.

lily.huo
06-17-2016, 06:49 AM
Thank you very much, Taqua . Yes, you are right! I wrote that unit test, then found it need another jar: bsf-2.4.0.jar,
so I added this dependency to my pom.xml. running my application , now there is none error , and the html report page can display , but none chart picture.
that position should be bar chart is blank. the pdf format report is correct , the chart picture is right.
I think this is my appliction's problem and the pentaho report is well all right. Thank you again!



Hi , it is a bit long and i have a same problem as you had . when i embeded a chart pentaho report on Java application , it also remind me a error :
"can't parse " and display all the font but charts .

i guess maybe i didn't add the chart show jar in my application , but i want to know if there are other code should be added except the jar file , could you please give me an example .

BTW, could you please tell me how can i do if i want to embed xaction file developed using Pentaho Design Studio ?


Thanks in advance !