I recently made an update to JasperReports library version 4.1.3. Previously, I had a report created with JasperReports 4.0.2, with the language being groovy. Running it with JasperReports 4.1.3 generates an exception (ClassCastException – cannot cast java.lang.String to java.lang.Boolean).
The exception is somewhat correctly generated, as I have set a string (e.g.: “abc”) for the PrintWhen Expression of a text field. The problem is that before updating to this library, the report worked, even with an expression like that.
An expression like: “any_string” was evaluated as true and an empty string was evaluated as false.
Is there a property that can be set in order to have the same behavior as before without changing the report? (I know that a solution would be to change the conditions to be proper boolean ones, but it’s not a viable solution for me, as there are lots of reports involved and lots of complex conditions).
Thank you!
After analyzing the change logs and the SVN logs for the Jasperreports library, I discovered that a change was made in the release 4.1.1, and the cast to the class is not done anymore. This is part of the refactoring regarding the deprecation of value class in expressions.
From the change log:
– value class property is now deprecated in expression objects; the type of
expression no longer needs to be specified;
The solution is to modify the print when expresion to be a correct boolean expression or to add a cast for each print when expression.