[#4841] - Concatenation of string in expression

Category:
Bug report
Priority:
Low
Status:
Resolved
Project: Severity:
Text
Resolution:
Fixed
Component: Reproducibility:
N/A
Assigned to:
1

Hi
I tried to use javascript in jasperreport by concatenating field value and string for example $V{totalAmount}.toFixed(2)+$F{Currency_label}
This work fine using the jasper studio.
When compile the report in java I've got an Exception java.lang.NoSuchMethodError: org.mozilla.javascript.ScriptRuntime.add(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/String;
After a couple of our searching on google I came out that jasperreport is using a olg version of Rhino V1.7R3 the current version of Rhino is V1.7.6. The issue is in the ScriptRuntime class where there the method add(Object String has been remove since V1.7R3) so i is not possible to concat using the + sign the workarround is to use the concat function. Is it planed to upgrade jasperreport to rhino 1.7.6 ? Is there another way to work arround without in order to be able to use the + sign

Regards
JP

v6.1
ritz's picture
2
Joined: Jun 26 2014 - 5:50am
Last seen: 5 years 11 months ago

7 Comments:

#1
  • Status:New» Assigned
  • Assigned:nobody» teodord

Hi,

I modified the /demo/samples/javascript sample shipped with the JR project distro to use this expression:
<textFieldExpression><![CDATA[$P{A}.toFixed(2) + "|blah|" + $P{B}.toFixed(2)]]></textFieldExpression>

The result was:
3.00|blah|5.00

So it appears to me that it worked, although the JR distro still uses Rhino 1.7R3.

Are you embedding JR Library into your own application? If so, can you double check to see which version of Rhino you have there?
Also, it would be good if you could attach here your JRXML and also provide the full stack trace of the exception.

Thanks,
Teodor

#2
  • Status:Assigned» Feedback Requested
#3

Right with Rhino 1.7R3 it work. I am embedding the last release which is 1.7.6 with a lot of improvement but with this the + concat doesn't work any more. Hence my question as 1.7R3 is a 2011 version when will jasper upgrade to latest version

#4

Hi,

The problem indeed occurs when the JRXML is compiled to *.jasper format using Rhino 1.7R3, but then it is filled in an application that uses Rhino 1.7.6.
To solve this problem, both applications: the one that compiles the report (probably JSS in your case) and the one that runs the compiled report, should run the same version of Rhino library.

I guess what you propose here is for Jaspersoft Studio to ship Rhino 1.7.6.

For now, I am upgrading JR Library source distro to use Rhino 1.7.6 and the JSS team would probably do the same for their distro.

Having said that, this is not necessarily a JR Library bug/problem, but I took the opportunity to upgrade anyway.

Thanks,
Teodor

#5
  • Resolution:Open» Fixed
  • Status:Feedback Requested» Resolved
#6

Hi Theodor

Yes my proposal is to upgrade JR to Rhino 1.7.6 us you said it is better to run both application on the same version. So if you upgrade the JR source library would be great do you thing that the distro would be available soon ?.
Thanks
JP

#7
  • Priority:Normal» Low
  • Severity:Minor» Text
  • Assigned:nobody»
Feedback