JasperReports: CONCATENATE function not found

匿名 (未验证) 提交于 2019-12-03 02:42:02

问题:

I'm developing some reports with Jaspersoft Studio.
I have a web app that should accept REST queries, and turn them into compiled reports.
So I have some of the JasperReports jars included:

  • groovy-all-2.0.1.jar
  • iText-2.1.7.js2.jar
  • jasperreports-5.2.0.jar

Problem is that when I compile my report and run from the Jaspersoft Studio, it works fine.
But when I compile and run it from my web app, it throws the exception:

net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :      Source text : CONCATENATE($V{startString}, "  -  ", $V{endString})     at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:244)     at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:591)     at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:559) ... Caused by: net.sf.jasperreports.engine.JRRuntimeException: Function CONCATENATE not found 

When I change my CONCATENATE call in the report it works fine.

So this leaves me with a solution that I'm missing one of the JasperReports jars, but which one?

回答1:

You should also add jasperreports-functions-5.2.0.jar to your classpath.

This library contains net.sf.jasperreports.functions.standard.TextFunctions class with CONCATENATE function.

You can find this artifact at http://jaspersoft.artifactoryonline.com/jaspersoft/jr-ce-releases Maven repository.

The snippet from my test pom.xml:

jr-ce-releaseshttp://jaspersoft.artifactoryonline.com/jaspersoft/jr-ce-releasesnet.sf.jasperreportsjasperreports5.2.0org.codehaus.groovygroovy-all2.0.1net.sf.jasperreportsjasperreports-functions5.2.0joda-timejoda-time2.1

The net.sf.jasperreports.jasperreports-functions:5.2.0 artifact depends on joda-time.joda-time:2.1 artifact - you should also add to classpath the joda-time-2.1.jar


Notes:

You can find more information in Custom Functions in Report Expressions article



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!