I've dealt with passing in multiple parameters, using them in field expressions and in the SQL queries.
I'm not looking for solutions here as I've found fixes for almost every issue (Some of them quite easy fixes as well), but I thought I'd share my experience so that some people could learn from the gotchas and mistakes that I've had to learn from.
Working on Jasper Reports has been quite a trial-by-fire for me, my employer has asked me to build around 20-30 reports and as I said, some of them are quite complex. Most of them have just consisted of a few fields in the detail section, but the bigger, more complex ones are around 60-70 fields in, which is where Jasper has it's short-comings. As I've had to change my SQL statements and manually type in every field. (Due to various issues with datatyping and making sure that datatypes can be changed in the database and not have to change the reports again.)
For example:
I've got a table called 'tableA' with the columns 'PK', 'Time', 'Name', and 'valueX'
PK is an integer, primary key of the table.
Time is set as a DateTime (java.sql.Timestamp)
Name is a VARCHAR(255) field
valueX is another VARCHAR, but it's length is set to MAX
These four fields are the only ones on the report, so it'll be easy enough, right?
The SQL statement is simply going to be
- Code: Select all
SELECT * FROM tableA
and now I'll be able to just shove some fields on the report.
So I go ahead and run that report and an exception will be thrown.
"java.io.NotSerializableException: net.sourceforge.jtds.jdbc.ClobImpl"
What the hell, right?. Well so far I've found that I'd get this every time anything is cast in the SQL as VARCHAR(), or VARCHAR(MAX). Which is a major annoyance, because my application requires those fields to be max length, I can't change the length of the fields, so it's now got to be done in the SQL.
My statement now becomes this:
- Code: Select all
SELECT
PK,
Time,
Name,
CAST(valueX AS VARCHAR(1000))
FROM
tableA
Not necessarily '1000', but some other number, I usually use 1000.
So I run the report, now, it works just fine. But now a client requirement means I need to change a column's data type to a date.
So once I've changed the datatype in my database, my report breaks again.
My statement has to change... Again.
This time, I'm having to cast the date, too.
- Code: Select all
SELECT
PK,
CAST(Time AS VARCHAR(1000)),
Name,
CAST(valueX AS VARCHAR(1000))
FROM
tableA
Everything works, regardless of the huge mess around I've had trying to get it to do so.
So my solution is ready for deployment, I export my solution and upload it to the app server, I transfer my report and any images I've used to make it look good, too.
All of the required plugins and beans are up, in particular, JasperReports bean and plugins.
I browse over to http://appserver.com:8080/ and check if it's working, download the JNLP and run it, head over to the report and try to run it.
Crashes and burns, something about uuids.
So I do quite a bit of digging around to found that the version of iReport I'm using is somehow too new, it's adding in a <uuid=""> attribute into everything I've got on the report.
I dig through the jrxml file and remove all instances of this tag, a simple regex in a decent text editor can do this for me, no big issue (Except figuring out why it was broken).
I upload the new versions of the reports and try to run them again.
I'm now getting a different error, about paragraph tags.
I've put some indentations on the text of some fields in the report and the version of the plugin I'm using doesn't like it.
So back in the jrxml, I remove all of the paragraph tags, again, easy enough with some regex (Also after figuring out the issue and how to fix it).
Back into the reports section, I run the report and finally, the report has worked!
But I notice something in the report that I need to change, so I go ahead and make the change in iReport and forget all about the uuids and paragraphs tagging issues.
I run the report again and it errors out, so I go digging through the settings and find the option for saving in compatibility mode for older versions, this solves both the uuid and paragraph tagging problems, which has now made things easy enough to save the reports for version 4.5.0, which is void of uuids and paragraph tags.
So why does Jasper have to be this fiddly? I had to spend hours trying to find the correct version of the plugin (Even though in the end it turned out the latest version was what I needed anyways.) and the correct version to save in compatibility mode with. Why doesn't the latest version of the plugin work with the latest version of iReport? Surely iReport can't just be adding in tags that can't be read by the plugin? There's been uuid issues since version 4.6.0 and we're up to 5.0.1 now.
Thanks for reading anyways, just thought I'd share my experiences with iReport/Jaser Reports and Servoy with anyone else that's having issues or who has had these issues in the past.