Jasper reports and iReport

Hey Jon,

I'm glad you got it to work. I'm looking forward to your plugin, although the hard part will probably always be the iReport and Java part. I've never developed a plugin before so I don't know if I can be of assistance. Are you going to put the Java stuff also inside the plugin directory ?

Do you think I could improve the description of the whole process ?

I suppose I left the log4j-1.2.13.jar because the one from the iReport lib was a lower version. I'm going to test however if it is also working with the version that is included in iReport and will let you know here.

Hey Jon,

I'm glad you got it to work. I'm looking forward to your plugin, although the hard part will probably always be the iReport and Java part. I've never developed a plugin before so I don't know if I can be of assistance. Are you going to put the Java stuff also inside the plugin directory ?

That's my plan. I've created a few plugins (some only shared between internal projects here at work and a couple released to the wild), so I'm not worried about that part. It also looks like I should be able to integrate jasperreports into the plugin and stay true to jasper's GPL licensing.

The one thing I'm still wondering about is that XmlJasperInterface.class file and where it comes from, how it's licensed, etc. It seems like it would be necessary to include it with the plugin, but do I need to include the source? Does it have it's own copywrite and license that needs to be included? Anybody know who originally wrote that code?

Do you think I could improve the description of the whole process ?

Not sure. One problem I ran into is my project uses RESTful routes, so I needed to do a little extra to generate the original xml file and the report, but I think including those instructions might have made it more confusing for people not using RESTful routes, and those of us who are should already know what we need to do. Other than that, it appears my whole problem was really my typo.

I suppose I left the log4j-1.2.13.jar because the one from the iReport lib was a lower version. I'm going to test however if it is also working with the version that is included in iReport and will let you know here.

I'm currently using the two log4j's that come in iReport and it seems to work, but I'm not doing anything complicated, so my not even be exercising that code to find out it's not good enough.

The download contains also the XmlInterface.java source file. In that file there is the e-mail address of the guy who wrote it. You could maybe mail him about it.

Hehe, I actually just found his address through a different route. But based on what you found, it looks like I've definitely got the right guy. So, we'll see what he says.

Hi, I used the HowTo to install JasperReports in my Rails-application. It works for rtf-files, but it doesn't work for pdf. No message in the logfiles :frowning: Anyone any idea? Sometimes even rtf doesn't work and I get a 'Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/ JRDataSource'. Anyone any idea for that? Thanks! Eike

Thanks to Herman Jansen for his work on this :slight_smile:

On the http://wiki.rubyonrails.org/rails/pages/HowtoIntegrateJasperReports

page in the example xml code it has an inconsistency ?

'LIST' (opening reference,versus, 'LOOKUP' closing reference) Would that cause a problem ?

I'm struggling to follow this tutorial. :frowning:

<?xml version="1.0" encoding="UTF-8"?> <customer_list_result>   ...... </customer_lookup_result>

Denis

I've finally achieved some measure of success... When I try to display data as PDF in IE , it now launched Adobe Reader, but gives me an error message

'The file is damaged and could not be repaired'.

Additionally, I now see that in the server console it generate output as follows: %PDF-1.4 %ooxe 3 0 obj <<Length 277/Filter/Flate.... an so on. -about 4 lines of garbage...

It looks like it might be an Adobe PDF header ... hmmm... must be the xmljasperinterface acting up.. java environment ??

jeez 1 it's so frustrating .....iReports looks so good :slight_smile:

Denis

Check again if you have all the necessary classes from the iReports lib directory.

Herman Jansen wrote:

Check again if you have all the necessary classes from the iReports lib directory.

Thank for your suggestion. I've actually re-installed everything from ground zero, because I had tried everything to resolve this issue. In the process I've upgraded to RoR ver 2.0 (I has been at 1.7). That involved jumping through a few hoops. I re installed iReports 2.0.4 and JasperReports 2.0.5(very recent release)

I had double checked the lib replication dimension, and they were identical, save for a version indicator in one file :- Log4J files...(two). I've used the latest version 1.2.13.

Just for the record....

Directory of C:\InstantRails\rails_apps.......jasper\lib

13/12/2006 10:20 188,671 commons-beanutils-1.7.jar 08/12/2003 20:50 165,119 commons-collections-2.1.jar 15/01/2008 20:32 26,388 commons-logging-1.0.2.jar 01/07/2005 13:21 1,553,403 itext-1.3.1.jar 15/01/2008 20:32 1,922,698 jasperreports-2.0.4.jar 20/12/2005 17:45 294,514 jcommon-1.0.0.jar 15/01/2008 20:32 1,212,369 jdt-compiler-3.1.1.jar 20/12/2005 17:45 1,072,312 jfreechart-1.0.0.jar 04/12/2005 18:00 358,180 log4j-1.2.13.jar 22/08/2007 15:48 909,270 poi-3.0.1-FINAL-20070705.jar 15/07/2004 22:46 1,781,922 xalan.jar

Directory of C:\jasper\iReport-2.0.4\lib <snip> 15/01/2008 20:32 188,671 commons-beanutils-1.7.jar 15/01/2008 20:32 165,119 commons-collections-2.1.jar 15/01/2008 20:32 26,388 commons-logging-1.0.2.jar 15/01/2008 20:32 18,404 commons-logging-api-1.0.2.jar 15/01/2008 20:32 1,553,403 itext-1.3.1.jar 15/01/2008 20:32 1,922,698 jasperreports-2.0.4.jar 15/01/2008 20:32 1,212,369 jdt-compiler-3.1.1.jar 15/01/2008 20:32 1,072,312 jfreechart-1.0.0.jar 15/01/2008 20:32 352,668 log4j-1.2.8.jar 15/01/2008 20:32 352,291 log4j-1.2.9.jar 15/01/2008 20:32 909,270 poi-3.0.1-FINAL-20070705.jar 15/01/2008 20:32 1,781,922 xalan.jar

Having re-checked everything and still having an Adobe launch with a corrupt file error, I tried it on another PC. It also has ROR version 2.0 , did NOT have ireports or Jasper installed, save for the files copied to the ...app/jasper/lib.

Amazing ! It worked :slight_smile: . Let joy be unconfined.

Now to figure out why that has happened ? My PC is :- IntelDualCore , 4 Gig Ram, Win XP SR2 , Java version SE 1.6.0_05-b13. InternetExplorer ver 7.0.5730.11 (This PC is dual boot with Vista 64).

The other PC is;- IntelDualCore , 2 Gig Ram, Win XP SR1 , Java version 1.5.03. InternetExplorer ver 6.

The value set returned by Request.env are more detailed on the former... I tested this by pasting some code into a view in mycookbook.com - as the simplest available environment.

See http://wiki.rubyonrails.org/rails/pages/VariablesInRequestEnv

I'm still puzzled as to why it should work on one PC and not another. Since the application was simply copied from one PC to the other as a folder within the rails_apps directory - with additionally copying the MySQL data folder.

If i do not resolve this, I could not deploy to any particular PC without the overhead of checking this aspect for all possible reports to generated... ?

Any thoughts on why the variance ? Seems like an environment issue ?

Sorry for goingon so long . Thanks for your interests and contributions here :slight_smile:

Regards,

Happy St. Patrick's day( tomorrow) from ireland :slight_smile:

Denis

Just for the record ; revisited

20/12/2005 17:45 294,514 jcommon-1.0.0.jar IS in ROR lib 04/12/2005 18:00 358,180 log4j-1.2.13.jar IS in ROR lib 15/01/2008 20:32 352,668 log4j-1.2.8.jar IS in ROR lib 15/01/2008 20:32 352,291 log4j-1.2.9.jar IS in ROR lib 15/01/2008 20:32 18,404 commons-logging-api-1.0.2.jar not in ROR lib

I have got Jasper Reports to work with Rails. I have blogged it - Ruby Rails Ruminations: Bringing Jasper Reports, Rails and Rjb together.

I would be interested to read comments.

I am going to try JRuby on Rails and use the inate JVM to do the same thing.

I did look at the ref in the last reply -very impressive - and i may go that way.

Meahwhile the saga continues.....

I've finaly got JasperXMLInterface and Ruby to work - consistently every time, producing PDF docs. (I did have to amend some of the suggested code to fix a path error - omission of APP at one point)

Now for the wrinkle.. It was intermittemtly breaking, and it took me a while pin it down.

Reproduce the problem by; run pdf report - works successfully, save it. close pdf close browser close ruby console close rails applicatiom dialog box I -> configure database vis MyPHPAdmin select Customer table Insert a record , save , browse close MyPHP I -> Rails applications -> Manage Rails applications Select app, Start it with Mongrel*(ruby console opens) select http://localhost:3000/customer_report (should produce a pdf listing customers) Adobe Reader displays an error message: There was an error opening the document. The file is damaged and could not be repaired.

Fix the problem by: close Adobe Reader Close browser close ruby console (=stops server) close Rails applications dialog box I -> config database MyPHPAdmin select database select table Customer browse delete last record close browser I -> Rails applications -> Manage Rails applications Select app, Start it with Mongrel*(ruby console opens) select http://localhost:3000/customer_report (should produce a pdf listing customers) Adobe Reader opens with the pdf listing - perfect !

Question: Is this normal behaviour ? Would you expect it to be damaged by the action of opening the database with PHPAdmin ? And what is damaged exactly ? It has to be some environment (Win XP?) issue ?

I would welcome comments.

Maybe one should not access the database with PHP ? (I reminded of the old joke - 'only whan i laugh' - Was that a Len Deighton book ?)

Regards

Denis

Hi,

I have also started working on integrating the jasper report and ruby on rails. I started with creating the report manually in iReport.

I created my XML file data source. Then I tried to create the report.

"Data—> Report query" in iReport was disabled even after i selected my data source. I don't know why it happens like this. I am not able to proceed further. Any guess???

Please help me to find out the issue.

Thanks in advance...

"Data—> Report query" in iReport was disabled even after i selected my data source.

Could it be that you have not yet opened (to create) a new file. Those buttonsare enabledafter File->New document ?

It does seem a little strange that you can create a data source first without starting a new document.... :slight_smile:

Denis

Thanks for you valuable suggestion. Today is the first day I started working on iReport. I was doing the same mistake as you said.

Now I am able to run the report from the XML. But I am getting a blank PDF. No data inside it.

Any guess why???

I have done all the coding for ROR and iReports integration as mentioned in http://wiki.rubyonrails.org/rails/pages/howtointegratejasperreports

When I run the URL in the browser I am getting a small alert message saying "The file is damaged and could not be repaired"

Any guess why it is coming???

Thanks Denis. That helped. There was a mistake with my xml file. I got it running successfully.

But I got the same problem again. I found out one of the reasons also. When I created the report design in the iReport UI, the height and width were some factors for the column headers.

When I run the report in iReport, the PDF was generated successfully. But when i tried that jasper with my rails application, the file damaged message was shown. When I adjusted the height and width of the fields in the report design, I got it working.

I'm glad for you :slight_smile:

It's intersting that the object width/height could be a cause of error. I did note that it warns you when the objects overlap the boundries by altering the colour of the object outline.

I wonder would you look at my post of 26.03.2008 16:16 and comment ? Are you in Linux or Windows ? and do you use PHPadmin. It still seems strange to me that the PDF file creation can be broken by using PHP admin.

Regards

Denis

Hi

I've got the same problem.

--- with pdf: both web-browser crash. with firebug i get this : <html> <body marginwidth="0" marginheight="0"> <embed width="100%" height="100%" name="plugin" src="http://localhost: 3000/admin/customer_report" type="application/pdf"/> </body> </html

But i don't know what to think about this

--- with rtf.

It works with IE & Firefox. But in both case The report is empty.

Any Idea of the problems??

I try to debug, but no success

Here is my param of my IO.popen call:

java -Djava.awt.headless=true -cp "F:/jasper_test/app/jasper/bin; F:/jasper_test/app/jasper/lib/commons-beanutils-1.7.jar; F:/jasper_test/app/jasper/lib/commons-collections-2.1.jar; F:/jasper_test/app/jasper/lib/commons-logging-1.0.2.jar; F:/jasper_test/app/jasper/lib/itext-1.3.1.jar; F:/jasper_test/app/jasper/lib/jasperreports-2.0.5.jar; F:/jasper_test/app/jasper/lib/jcommon-1.0.0.jar; F:/jasper_test/app/jasper/lib/jdt-compiler-3.1.1.jar; F:/jasper_test/app/jasper/lib/jdt-compiler.jar; F:/jasper_test/app/jasper/lib/jfreechart-1.0.0.jar; F:/jasper_test/app/jasper/lib/log4j-1.2.13.jar; F:/jasper_test/app/jasper/lib/poi-3.0.1-FINAL-20070705.jar; F:/jasper_test/app/jasper/lib/xalan.jar" XmlJasperInterface -ortf -fF:/jasper_test/app/reports/custrep.jasper - x/customer_list_result/invoice_customers/customer

Here is my xml_data param of the pipe.write method <?xml version="1.0" encoding="UTF-8"?> <customer_list_result>   <invoice_customers> <customer>   <city>smalltown</city>   <id type="integer">1</id>   <name>A Nuino</name> </customer> <customer>   <city>big town</city>   <id type="integer">2</id>   <name>3D-Design</name> </customer> <customer>   <city>Expensivetown</city>   <id type="integer">3</id>   <name>International Inc.</name> </customer>   </invoice_customers> </customer_list_result>

Does anybody see something wrong.

If i run this line "XmlJasperInterface -ortf -fF:/jasper_test/app/reports/custrep.jasper - x/customer_list_result/invoice_customers/customer" in my command line interface (win xp), I've got this error: [fatal Error] :3:1 Content is not allowed in prolog.

Does it mean something to someone??