1

When I try to compile a simple JasperReport with built-in functions I get this errror : 

net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
1. The method DATE(int, int, int) is undefined for the type built45in45fonction45test_1596551722309_451926
                value = DATE(2068,05,16); //$JR_EXPR_ID=8$
                        <-->
2. The method DATE(int, int, int) is undefined for the type built45in45fonction45test_1596551722309_451926
                value = DATE(2068,05,16); //$JR_EXPR_ID=8$
                        <-->
3. The method DATE(int, int, int) is undefined for the type built45in45fonction45test_1596551722309_451926
                value = DATE(2068,05,16); //$JR_EXPR_ID=8$
                        <-->
3 errors
.
    at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:229) ~[jasperreports-6.13.0.jar:6.13.0-46ada4d1be8f3c5985fd0b6146f3ed44caed6f05]
    at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:358) ~[jasperreports-6.13.0.jar:6.13.0-46ada4d1be8f3c5985fd0b6146f3ed44caed6f05]
    at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:344) ~[jasperreports-6.13.0.jar:6.13.0-46ada4d1be8f3c5985fd0b6146f3ed44caed6f05]
    at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:609) ~[jasperreports-6.13.0.jar:6.13.0-46ada4d1be8f3c5985fd0b6146f3ed44caed6f05]

Context : SpringBoot 2.3 project

In the pom.xml :

<dependency>
    <groupId>net.sf.jasperreports</groupId>
    <artifactId>jasperreports</artifactId>
    <version>6.14.0</version>
</dependency>
<dependency>
    <groupId>net.sf.jasperreports</groupId>
    <artifactId>jasperreports-functions</artifactId>
    <version>6.14.0</version>
</dependency>

In the Java class :

final InputStream stream = this.getClass().getResourceAsStream("/built-in-fonction-test.jrxml"));
final JasperReport jasperReport = JasperCompileManager.compileReport(stream); // <- KO :-(

The simple report used for this test (built-in-fonction-test.jrxml) :

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.12.2.final using JasperReports Library version 6.12.2-75c5e90a222ab406e416cbf590a5397028a52de3  -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="built-in-fonction-test" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="ed842882-2dc9-4572-975b-6f1a74cc9aff">
    <queryString>
        <![CDATA[]]>
    </queryString>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="79" splitType="Stretch">
            <textField>
                <reportElement x="200" y="20" width="100" height="30" uuid="8f57fff7-712b-40c7-9a9a-62d4cec96a2c"/>
                <textFieldExpression><![CDATA[DATE(2068,05,16)]]></textFieldExpression>
            </textField>
        </band>
    </title>
</jasperReport>

Other reports without any built-in function compile well in this project.

Any help is welcome :-)

Alex K
  • 22,315
  • 19
  • 108
  • 236
  • Did you try to compile report at Studio? Does it work? – Alex K Aug 04 '20 at 15:13
  • Looks like you are missing *jasperreports-functions* at cp – Alex K Aug 04 '20 at 15:19
  • 1
    You have 6.14.0 in pom.xml, but the stacktrace shows jasperreports-6.13.0.jar. Could you confirm the version that you are actually using? – dada67 Aug 04 '20 at 15:28
  • Report compiles with Jaspersoft Studio. Indeed with the jasperreports-functions dependency it works ;-) ! It was an issue with my IDE (IntelliJ). With maven command line it works :-) mvn clean compile + mvn spring-boot:run : OK. Thank you ! – Olivier Deslandes Aug 06 '20 at 09:01

0 Answers0