Archive

Archive for July, 2008

Running JasperReports with subreports in an app server environment

July 29th, 2008

I’ll start with the moral of the story: read documentation carefully as it may contain the answer you seek.  These things are covered in the pay-for documentation available from JasperSoft but you have to skip around a bit to get what you need.

With that out of the way I’ll note that if you don’t buy The Definitive Guide to JasperReports (or support for that matter) you don’t seem to have many good options for documentation aside from the forums which are hit or miss at best.  And with the new version of the  JasperForge website, which is unfortunately worse than the old one, even that is a dicey proposition.  Because I now have clarity on how to get subreports working in an application server environment I’m going to share with others that they may avoid the struggle I did ;)   In my particular case the application server is Weblogic 9.2 but I suspect the application server itself is irrelevant.  The issue is with how JasperReports runs embedded subreports.

Briefly, the default method to run subreports is to use multiple threads.  Each subreport inside a report gets its own Runnable via a call to JRThreadSubreportRunnerFactory.createSubreportRunner().   The default subreport runner is set via a property net.sf.jasperreports.subreport.runner.factory in the file default.jasperreports.properties (located in the JasperReports jar file).  The default for this is net.sf.jasperreports.engine.fill.JRThreadSubreportRunnerFactory.  Unfortunately this doesn’t work so well in an environment that discourages the use of multiple threads like an application server environment.

The solution from the guys at JasperSoft was to refactor the subreport runner facilities so that interchangeable implementations could be used. The facility that should be used to run reports with embedded subreports in an application server environment is JRContinuationSubreportRunner and it’s corresponding factory JRContinuationSubreportRunnerFactory.   These require a different version of the JasperReports jar file as well as an additional jar from the Apache Commons project both of which are included with the JasperReports distribution.  We now need to use jasperreports-2.0.5-javaflow.jar in place of jasperreports-2.0.5.jar (in my case….your case migh be a different version number).  We also need to use commons-javaflow-20060411.jar.

So we’re good right?  Problem solved.  Well…not so fast.  There are some oddities that need to be dealt with first.

  1. In the javaflow version of the JasperReports jar the default is still to use the threaded version of the subreport runner instead of the continuation version.  Huh?  Since we’re specifically using that version of the jar shouldn’t the default actually be the continuation version of the subreport runner?
  2. The javaflow version of the jar still contains the threaded subreport runner which is kind of confusing.  I’m not sure why I’d want to use that since I’m already using a special version of the jar anyhow to *avoid* threading issues.  I suppose it provides a fall-back but to me it’s confusing.
  3. The regular jar file contains the continuation version of the subreport runner but you can’t use it since it isn’t instrumented for javaflow use.  Again this is confusing and I can’t understand why those classes are there if they can’t even be used.  If you try to use it you get the following stack trace:

    java.lang.IllegalStateException: stack corruption. Is class net.sf.jasperreports.engine.fill.JRContinuationSubreportRunner instrumented for javaflow?
    at org.apache.commons.javaflow.bytecode.StackRecorder.execute(StackRecorder.java:102)
    at org.apache.commons.javaflow.Continuation.continueWith(Continuation.java:170)
    at org.apache.commons.javaflow.Continuation.startWith(Continuation.java:129)
    at org.apache.commons.javaflow.Continuation.startWith(Continuation.java:102)
    at net.sf.jasperreports.engine.fill.JRContinuationSubreportRunner.start(JRContinuationSubreportRunner.java:57)
    Truncated. see log file for complete stacktrace

    If I can’t use it why is it there in the first place?

The last “gotcha” is the need to set up a properties file so that you override the default of using the threaded version of the subreport runner.  This is an easy workaround however as it only requires a couple of things:

  1. Set a system property called net.sf.jasperreports.properties that points to a properties file that contains the required JasperReports properties.  It doesn’t need to be a specific one for JasperReports if you already have a properties file for other things.  It can point to that or you can create a new one.The other thing to note about this is that you only need provide the properties that you have to override.  The reporting framework is set up to use defaults for the ones you don’t provide.  If you’re paranoid copy the one that comes with the jar file and change what you need in there and point to it with the property mentioned above.
  2. Paste the following in that properties file:
    net.sf.jasperreports.subreport.runner.factory=net.sf.jasperreports.engine.fill.JRContinuationSubreportRunnerFactory

Now everything should work.  Let’s recap the steps:

  1. Add the jasperreports-2.0.5-javaflow.jar to your classpath (or whichever version of JasperReports you are using).
  2. Add the commons-javaflow-20060411.jar to your classpath (or whichever version ships with your version of JasperReports).
  3. Set a system property called net.sf.jasperreports.properties that points to a properties file that contains the required JasperReports properties.
  4. Paste the following in that properties file:
    net.sf.jasperreports.subreport.runner.factory=net.sf.jasperreports.engine.fill.JRContinuationSubreportRunnerFactory

I hope this post is useful to someone.  I didn’t struggle all that long with this but I definitely would have appreciated having some good documentation without having to pay for it.

Update: As of JasperReports 3.0.1 Steps 3 & 4 above should no longer be necessary as the JRContinuationSubreportRunnerFactory is now the default.

  • Share/Save/Bookmark
Author: Categories: Java Tags: , ,

emusic.com cost going up – songs end up cheaper

July 23rd, 2008

Yeah it sounds odd doesn’t it? It’s true though.

I’ve been a subscriber for quite awhile at the $9.99 a month level. At that level I’ve been receiving 30 downloads a month which, if you do the math quickly, about $0.33 a track.

I just received a note that the cost is going up $2 a month for the basic package of 30 tracks a month. However that’s for new subscribers. For “old-timers” emusic.com is giving an extra 10 downloads a month so even though the monthly cost is going up the actual per-track price is $0.30 so I end up paying less.

They’re also giving out a one-time booster of 10 tracks next month which is quite nice.

I really wish more companies operated this way. Obviously it doesn’t cost emusic much to give their existing customers 10 extra tracks a month. Why aren’t any of the “utility” companies (cell phone, tv, etc.) doing this stuff when they can easily afford it? We all have heard the stories that it costs more to get a new customer than to retain one. Why are the utilities so damn awful then?

  • Share/Save/Bookmark
Author: Categories: General, Music Tags: , ,

The ultimate email smackdown -or- “that Janus-faced verbal monstrosity”

July 21st, 2008

Follwing are two emails I received one day about a month ago.    Names, etc. have been sanitized to protect the guilty.   Enjoy.

The opening shot

All,
I have found that it is time for me to once again remind everyone to remove the grammatically incorrect and unnecessary “and/or” construction from use throughout ….  Sorry, but I’ll blame being a stickler on my Jesuit education!  I’ve recently seen “and/or” slip into … publications again after an absence of several years.  It seems as though it’s like a virus that never really goes away.  While this might seem like a quite minor issue, it’s something that we can easily correct and our members and our customers will appreciate the fact that we care even about the small details of our work.
“And/or” basically shows that writers don’t really know what they mean and they’re trying to cover up that fact.  They’re being sloppy.
Acceptable:
1.  “and.”  Example. Charlotte and I will speak at the meeting.  This means that both of us will speak.
2.  “or.”  Example:  Charlotte or I will speak at the meeting.  This means that both may speak. It also means that only one of us might speak.  It intentionally leaves the situation ambiguous.
3.  “either….or.”  Example:  Either Charlotte or I will speak at the meeting.  This means that one of us will speak but it rules out both of us speaking.
So, please correctly use our language and avoid trendy (and sloppy) constructions.
Thanks, …

The Finishing Salvo

Hi all,

<name removed>’s quite proper note was prompted by my unfortunate use in an e-mail of the term that one commentator has called “that befuddling, nameless thing, that Janus-faced verbal monstrosity.”

To salve my professional conscience, please allow me to note the following in his jeremiad:

  1. excessively tentative phrasing (e.g., “It seems as though it’s like”);
  2. three compound sentences punctuated insufficiently; and
  3. a draconian sense of what constitutes trendiness. “And/or” arose in the legal discourse of the nineteenth century. I realize that this is practically yesterday on the Jesuitical timescale, but the term’s vintage is scarcely comparable to that of, say, “impact” (as a verb) or “a’ight.”

To be more positive, I do admire an author who knows the difference between “may” and “might” and who appreciates that good use of grammar is next to godliness.

Precisely and / or sincerely,

  • Share/Save/Bookmark
Author: Categories: General Tags: , ,

Critters and corn

July 21st, 2008

I’ve got something hacking on my corn. I suspect it’s the squirrels as they should be the only thing that can get over the fencing I have around the corn without bringing down the fence. I know its not some kind of bug…the damage looks like its from teeth and everything is shredded.

Today I went out and bought some Bobbex-R to spray on the corn in the hopes that it will keep the critters away. The stuff certainly isn’t cheap so I hope it does work. By the smell I’m sure it will ;)

  • Share/Save/Bookmark

Phone menu navigation

July 8th, 2008

You hear the whispers coming out of co-workers, hushed tones with odd inflections repeating words like ‘yes’, ‘no’, ‘customer service’. Is this some weird conversation with a loved one? Then it dawns on you that your co-worker is busy navigating the world of a voice-recognition-based phone system.

Almost everyone has used one of these systems by now. Many companies are using them these days and the trend seems to be moving away from number-based (”please hit 1 if you require immediate medical attention”) to voice-recognition-based (”please say yes if you require immediate medical attention”) phone menu navigation systems. The question is why?

There is nothing inherently better about these systems and I’d argue that in fact they are worse. In most cases hitting a number on the keypad would be quicker. In all cases it is certainly not as disruptive as navigating a voice-based menu system. I suppose there is one situation in which a voice-based system could be better and that would be a menu that gets very deep with options.

With a voice-based system it would probably be easier to skip levels of the menu depending on what the person is saying. Something like “pay my bill” could certainly save time if the keypad-based option required inputting more than 2 numbers to navigate down in to the menu system. In my experience with these systems though I am not seeing this savings.

Most of the systems have voice input that is closely tied to menus that would be equivalent to the keypad-based systems. I just don’t see the savings in time and see a lot more aggravation. I have had, on more than one occassion, had to repeat myself multiple times to be understood. Higher levels of background noise really mess with the voice recognition. In some instances I have even been transferred to a human because the voice recognition can’t understand what I’m saying.

Keep the keypad-based systems guys. They are the less annoying option.

  • Share/Save/Bookmark

The Pickens Plan: why natural gas vehicles???

July 8th, 2008

I just finished taking a look at the Pickens Plan and it has me scratching my head.

It states:

We currently use natural gas to produce 22% of our electricity. Harnessing the power of wind to generate electricity will give us the flexibility to shift natural gas away from electricity generation and put it to use as a transportation fuel — reducing our dependence on foreign oil by more than one-third.

Why would we want to build the infrastructure to support natural gas-powered vehicles? Keep the natural gas as the power station where it belongs. The infrastructure to support electric vehicles has been in places for ages now and electric vehicles would account for the vast majority of driving that people do.

The answer is staring us in the face. Why do we keep ignoring it?

  • Share/Save/Bookmark

Summer festivals, big crowds, and why the Taste of Chicago sucks

July 5th, 2008

I still can not understand why people flock to the Taste of Chicago on July 3rd every year.   And every year the crowds seem to get larger.  Oh sure I understand that there is a fantastic fireworks display there every year.  In fact I used to enjoy it myself for quite a few years when I lived in the city.  But maybe it’s as I get older I call in to question people’s sanity when I see the crowds of people heading to the lakefront every July 3rd.

I’ll relate a little story of my own.  About 10 years ago a friend and I went to the Taste of Chicago both for  the food and for the fireworks.   We were hanging out in the area around Buckingham Fountain in Grant Park waiting for the fireworks to start.   It seemed like a good area to watch the display.  Unlike most of the areas right down by the lakefront there was actually some room to move around.   On the 3rd people are generally packed in like sardines in a can, there is absolutely no room to move.

A little while into the fireworks we heard a big roar behind us.   I turned around and got a quick glimpse of a mass of people rushing toward us.  I didn’t get much more than a quick look because at that point the crowd had reached us and I was jammed into a moving wall of people.   I was actually physically picked up off my feet and moved about 30 feet as the people kept stampeding forward trying to get away from whatever it was that had caused the stampede in the first place.  I had heard about situations like this.  I had just never been in one and never want to be in one again.

After it was all over people’s belongs were scattered all over the place and I saw several very small children who were separated from their families screaming and crying.  I can’t say that I felt any better than those kids did.  My nerves were jangled (in fact for a few days) and my friend and I got out of there as quickly as we could.   Unfortunately for me I was so nervous and walking so quickly that on the way out I stepped on a flattened aluminum can that was sitting in a pool of slick goo that is always on the streets and sidewalks during the Taste.  I fell flat on my back to the chorus of laughs coming from some group of drunk fools that witnessed my fall.  I didn’t care too much though…I just wanted to get the hell out of there.

Turns out that members of two rival gangs decided to mix it up close to the area where my friend and I were standing.  Guns and knives were brought out and people started panicking.   Apparently the years haven’t changed much.  I heard a woman call in to the John Williams Show on WGN radio this morning talking about a similar situation.

According to the story she and her boyfriend chose this past July 3rd to make their first visit to the Taste of Chicago and brought some friends that were in town from Sacramento, CA.  She pointed out the crowds, the being packed in so tight you could barely move, the claustrophobia from being in that situation, all of these things being familiar to anyone who has been to this festival on that particular day.   She then talked about how some gang-bangers decided to start mixing it up and caused another stampede.  She and her companions were caught in a bad situation and she said she never wanted to go there again.

I’m not sure what they can do about it.  It isn’t as if you can count people coming in to that area and then just block it off.  I certainly will never go there again on July 3rd.  It took years for me to go back even on another day but I will refuse to ever go again on a day when it is that packed full of people.  It isn’t fun.  It most certainly is dangerous.  The caller to the radio show suggested that they just cancel it.  Fat chance since it’s such a huge money maker.

The best bet is just to avoid it and go during lunch during the week.  It certainly is more accessible then.  But it still sucks.

  • Share/Save/Bookmark
Author: Categories: General Tags: , , ,