Sharing my experiences with Jasper Reports and iReport

I have recently been spending a lot of time using Jasper Reports and building rather complex reports, more specifically with Jaspersoft’s iReport.
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

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:

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.

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.

It’s a mystery to me why anyone uses iReport/Jasper anymore. https://www.servoyforge.net/projects/velocity-report, end of story.

We have several I-report report-designers at work for quite some time now who produced many, many jasper reports, some very complex.
We never encountered these casting issues up to now.

We are very happy with jasper reports, end of story.

Regards,

+1

david:
It’s a mystery to me why anyone uses iReport/Jasper anymore. https://www.servoyforge.net/projects/velocity-report, end of story.

Sure, velocity has his purpose, but
did you try to build a pixel perfect invoice layout, with all the wishes of a client, like custom font embedding, multiple bands, sub, sub sub, summary, etc…

that’s hell in Velocity, and a snap in iReport…

Harjo:

david:
It’s a mystery to me why anyone uses iReport/Jasper anymore. https://www.servoyforge.net/projects/velocity-report, end of story.

Sure, velocity has his purpose, but
did you try to build a pixel perfect invoice layout, with all the wishes of a client, like custom font embedding, multiple bands, sub, sub sub, summary, etc…

that’s hell in Velocity, and a snap in iReport…

I totally disagree :) Much easier to do with servoy server-side data generation, html templates and snippets, and css. And these are commonly available skills for new programmers and designers these days.

I’m happy that you are happy :-)

Harjo:

david:
It’s a mystery to me why anyone uses iReport/Jasper anymore. https://www.servoyforge.net/projects/velocity-report, end of story.

Sure, velocity has his purpose, but
did you try to build a pixel perfect invoice layout, with all the wishes of a client, like custom font embedding, multiple bands, sub, sub sub, summary, etc…

that’s hell in Velocity, and a snap in iReport…

@David:
For once I’m glad to say we totally agree! ;)

@Harjo:
Embedding custom fonts is dead easy in Velocity. Just put your ttf files in a /fonts subfolder of your /reports folder and push them using plugins.VelocityReport.installFonts() in your solution onOpen method (for Smart client, in Web client you don’t even need that step), then you can use them in your CSS.

As to achieve pixel perfect layouts, you can use CSS positionning and precise width/height, so it’s a matter of being efficient enough in HTML/CSS (which is pretty much a required skill nowadays), and definitely doable.

And “multiple bands, sub, sub sub, summary, etc” are done when you build your context, using either calcs/aggregates and/or simple Servoy looping + arithmetic in JavaScript and a few #if / #foreach in your templates, maybe you don’t have a visual iReport group/band builder but it’S much more flexible than that and it’s all Servoy based JavaScript so as long as you are efficient in Servoy/JavaScript you should be able to build pretty complex reports with any level of grouping in Velocity.

Hell! If you want, you can even embed in a straight Servoy form a little report layout builder and give that to your clients so that they can choose what to group on, and what level of details/columns they want along with various other ways to customize their reports, like I did for a client’s project:

[attachment=0]ReportLayoutBuilder.png[/attachment]
Now try that with Jasper Reports…

HI Patrick, thanks for this.

I know what Velocity does, and this Report builder you show, is very cool, but before we have build this in Servoy, I have my report finished in 10% of the time! :-)

Harjo:
I know what Velocity does, and this Report builder you show, is very cool, but before we have build this in Servoy, I have my report finished in 10% of the time! :-)

Hmm…I think you are confusing creating a report with creating a report builder here. ;)

Anyway, I guess it all depends on what tool you know best. If you haven’t worked with iReport then the editor is pretty daunting. Same goes for if you haven’t worked with the Velocity Template Language (VTL) then this can be daunting too and on top of that you need to know how to work with (X)HTML and (optionally) CSS . But even for that last part there are nice GUI editors as well.

I for one prefer Velocity (and I even hand-code my CSS/HTML).
But perhaps an easy (for users) Velocity Report Builder might be an interesting ServoyForge project.
Any (part)takers ?

ROCLASI:
But perhaps an easy (for users) Velocity Report Builder might be an interesting ServoyForge project.
Any (part)takers ?

That would be a great addition to the Velocity take-up and one we would support, perhaps even with a donation as contribution to the project!

+1

ROCLASI:
Anyway, I guess it all depends on what tool you know best. If you haven’t worked with iReport then the editor is pretty daunting. Same goes for if you haven’t worked with the Velocity Template Language (VTL) then this can be daunting too and on top of that you need to know how to work with (X)HTML and (optionally) CSS . But even for that last part there are nice GUI editors as well.

I for one prefer Velocity (and I even hand-code my CSS/HTML).

Velocity reports is technology everyone should be learning. It’s basics skills now for new programmers and applies to many areas besides Velocity. It will even help your Servoy server-side javascript abilities. At least it has for us – we’re starting to code with patterns and tricks learned from the client-side world.

iReports/Jasper approach is fast until there is that one arcane thing that sucks 10 hours out of your day trying to figure out (happens with every tool). I’d rather invest that time on relavent additive technology. Figure something out in Velocity and it will help you out in many areas.

Getting your team ramped up in the Velocity approach has far more value that the iReport/Jasper approach in my opinion. And in the end, you are just as fast at building reports.

Some defence points for Jasper :

  1. I think a graphical report builder with a high level of WYSIWYG in terms of lay outing graphical elements is of great importance for a lot of users worldwide.
  2. We pass the sql query from a foundset to the jasper engine and through the sql query in the jasper report we can get, sort, group etc. all data related to the foundset data we want
    only for that one report. This gives understandable a lot of report power where we as Servoy developers are not involved; more time to drink coffee :D
    I think that with Velocity all that data mining should be done in Servoy code ? Correct me if I’m wrong.

I find this discussion very valuable !

Regards,

lwjwillemsen:

  1. I think a graphical report builder with a high level of WYSIWYG in terms of lay outing graphical elements is of great importance for a lot of users worldwide.

Each time I hear that argument, I have a hard time picturing end-users digging into iReport: I’ve NEVER seen that in many years I’ve used JasperReport. It just doesn’t happen… The truth is that you need to be a specialized report designer or a skilled developer to build reports, not a user.

As to passing a foundset SQL, I find that approach a waste: you realize that you’ve already queried the database once to get your foundset, right? And now you’re going to query it again in Jasper using that method… Either pass the foundset or use Velocity and you’ll get a boost in performance.
And yes in Velocity you would do that in Servoy - but you would drink your coffee while a HTML designer is doing your pretty template ;)

lwjwillemsen:
This gives understandable a lot of report power where we as Servoy developers are not involved

I’ll give you this one for simple reports a user can do and I think this is where Patrick’s report builder app would fill the gap nicely.

My perspective of reporting is that almost always a developer is involved. Casting rtf fields to embedding fonts for pdf output to pulling in that one piece of data that is three relations away—iReport doesn’t magically make this stuff easy anymore than Velocity.

Again, agreeing with Patrick. Don’t get used to it :)

Hi David,

My perspective of reporting is that almost always a developer is involved.

This one is indeed critical for us. Over the years in our firm the large number of reports that were build for our end-users by non-developers have proved
in our case :

Almost never a developer is involved in report design !

lwjwillemsen:

My perspective of reporting is that almost always a developer is involved.

This one is indeed critical for us. Over the years in our firm the large number of reports that were build for our end-users by non-developers have proved
in our case :

Almost never a developer is involved in report design !

This mean that you have dedicated report designer(s)… Knowing that there are very little specialized resources around in this field I’d though this is worse.
Think also how easily you would find good HTML designers as opposed to report designers and do the math.

This mean that you have dedicated report designer(s)…

No, we don’t have… We gave colleagues (with no reporting experience other then our own legacy foxpro very limited text style reporting) a short course in jasper design, sql queries and our data model and off we went.
Some of those colleagues were also trained in writing xsl stylesheets for import and export data purposes.

Regards,