6

Using Jasper Reports 5.6.1. Added some text functions to a previously working text field jrxml (just want to truncate if longer than 75 chars). Works in iReport Studio, but not in Java.

<textFieldExpression><![CDATA[IF(LEN($F{AccountName})<75,$F{AccountName},LEFT($F{AccountName},75)+"...")]]></textFieldExpression>

Error message:

Error occured while trying to fetch the HTML Output from the Jasper     Service (Errors were encountered when compiling report expressions class file:
1. The method LEN(String) is undefined for the type ICC_1422636250096_198427
            value = IF(LEN(((java.lang.String)field_AccountName.getValue()))<75,((java.lang.String)field_AccountName.getValue()),LEFT(((java.lang.String)field_AccountName.getValue()),75)+"..."); //$JR_EXPR_ID=9$
                       <->
2. The method LEFT(String, int) is undefined for the type ICC_1422636250096_198427
            value = IF(LEN(((java.lang.String)field_AccountName.getValue()))<75,((java.lang.String)field_AccountName.getValue()),LEFT(((java.lang.String)field_AccountName.getValue()),75)+"..."); //$JR_EXPR_ID=9$
                                                                                                                                 <-->
3. The method LEN(String) is undefined for the type ICC_1422636250096_198427
            value = IF(LEN(((java.lang.String)field_AccountName.getOldValue()))<75,((java.lang.String)field_AccountName.getOldValue()),LEFT(((java.lang.String)field_AccountName.getOldValue()),75)+"..."); //$JR_EXPR_ID=9$
                       <->
4. The method LEFT(String, int) is undefined for the type ICC_1422636250096_198427
            value = IF(LEN(((java.lang.String)field_AccountName.getOldValue()))<75,((java.lang.String)field_AccountName.getOldValue()),LEFT(((java.lang.String)field_AccountName.getOldValue()),75)+"..."); //$JR_EXPR_ID=9$
                                                                                                                                       <-->
5. The method LEN(String) is undefined for the type ICC_1422636250096_198427
            value = IF(LEN(((java.lang.String)field_AccountName.getValue()))<75,((java.lang.String)field_AccountName.getValue()),LEFT(((java.lang.String)field_AccountName.getValue()),75)+"..."); //$JR_EXPR_ID=9$
                       <->
6. The method LEFT(String, int) is undefined for the type ICC_1422636250096_198427
            value = IF(LEN(((java.lang.String)field_AccountName.getValue()))<75,((java.lang.String)field_AccountName.getValue()),LEFT(((java.lang.String)field_AccountName.getValue()),75)+"..."); //$JR_EXPR_ID=9$
                                                                                                                                 <-->
6 errors
)

I checked packages in jasperreports-5.6.1.jar file, includes functions package. Exhaustive web search turned up nothing. What could it be?

Bill Dolan
  • 359
  • 1
  • 4
  • 12
  • Possible duplicate of [JasperReports: CONCATENATE function not found](http://stackoverflow.com/questions/19450214/jasperreports-concatenate-function-not-found) – Alex K Feb 16 '17 at 16:30

2 Answers2

9

I have a similar error message. Where you able to resolve this? Works fine in Jaspersoft Studio 6.0.1, but throws this when compiling w/ Java:

The method IF(boolean, BigDecimal, BigDecimal) is undefined for the type Blank_A4_1_1423164610392_674232

Update: I was able to solve this by including the functions jar on my classpath. See that if that works for you. See jasperreports-functions-5.6.1.jar at http://sourceforge.net/projects/jasperreports/files/jasperreports/JasperReports%205.6.1/

angrycrab
  • 830
  • 1
  • 9
  • 23
  • What the heck. This actually worked. I was having similar issues as well to TC, then I decided to follow this and added the Jasper-Functions dependency (https://mvnrepository.com/artifact/net.sf.jasperreports/jasperreports-functions/6.20.0) ,in addition to Jasper-Reports and now my reports generates(still have issues, but at least working better then previously) – Erik Sep 30 '22 at 09:54
0

When using GlassFish, verify that you have all jasper libraries on your production server. They should be under glassfish/domains/domain1/lib/ext. If the jars are not there (or some of them, such as the fonts or some other not non-requisite lib) you might experience the behavior you are describing.

ouflak
  • 2,458
  • 10
  • 44
  • 49
Remy
  • 1