Jasper reports and iReport

I've got this error: [fatal Error] :3:1 Content is not allowed in prolog.

It could be a malformed XML stream....

See http://www.judahfrangipane.com/blog/?p=53

Could this be the reason?

quotes from above link - The link does not work for me at present for some reason.

QUOTE: In an XML document the first thing before anything else you declare the type like so:

Correct:

PLAIN TEXTXML: <?xml version="1.0" encoding="utf-8"?>

Incorrect:

PLAIN TEXTXML: helloworld<?xml version="1.0" encoding="utf-8"?>

Note: The text formatter that I use adds a space between the less than sign and first question mark. That should not be there. In your document do not include the space.

Anything before the first character generates this error. If you do not see any characters you may have an invisible character. Then you would have to erase (backspace) up to that first character and retype the xml declaration or take a similar approach. END QUOTE:

QUOTE: Suggestions:

- Copy the text in your file and paste it into Notepad. Notepad strips or converts non standard codes. It is not fool proof but seems to work in most cases.

- Create a new file using your standard process. Copy the contents of your original file and paste them into the new file. The content being everything minus the beginning and end tags. END QUOTE:

Denis :slight_smile:

Hi Jef,

If your report is blank you most likely did not tick the box in the connection properties that says : use the report XPATH expression when filling the report

Regards

Denis

Attachments: http://www.ruby-forum.com/attachment/1810/test1.xml

Also make sure to select XPATH2 as the query type and define the query as per attached ie. the XML tags:- <customer_list_result>   <invoice_customers>    <customer>

become:

/customer_list_result/invoice_customers/customer

in the XPATH2 query window.

Denis

Attachments: http://www.ruby-forum.com/attachment/1811/test.sql

Could u send me your example app that work. It could help me.

your email address ?

Denis

Sorry

jfferriere@gmail.com

thanks

Hi,

I have got some problem. I have integrated the JasperReport with my ROR application.

When I use "pipe.read" it reads the stream but not fully. As there is a special character which ruby takes as a EOF character. It's hex value is "0x1a". When this character is reached, ruby stops reading the stream.

Please give a suggestion to solve this issue.

Thanks in advance...

Hi,

I noticed a change in the document.rb file on IntegratingRubyAndJasperReports. (It is difficult to determine the changes that are made due to the method of updating the wiki :slight_smile:

The mode needs to be set as 'w+b' for Windows. This seems to have improved the stability of my PDF reports. I thought you might be interested. It COULD be the cause of your error ?

Code fragment follows -note MODE is SET TO "w+b" for Binary mode in WINDOWS. and passed as 'mode' to the Java call.

Regards Denis

when /mswin32/         mode = "w+b" #windows requires binary mode         #Dir.foreach("app/jasper/lib") do |file|         Dir.foreach(Dir.getwd+"/app/jasper/lib") do |file|         interface_classpath << ";#{Dir.getwd}/app/jasper/lib/"+file if (file != '.' and file != '..' and file.match(/.jar/))          end       else         mode = "w+"         Dir.foreach(Dir.getwd+"/app/jasper/lib") do |file|         interface_classpath << ":#{Dir.getwd}/app/jasper/lib/"+file if (file != '.' and file != '..' and file.match(/.jar/))         end       end       result=nil

      # removed--------------       #IO.popen "java -Djava.awt.headless=true -cp \"#{interface_classpath}\" XmlJasperInterface -o#{output_type} -f#{Dir.getwd}/app/reports/#{report_design} -x#{select_criteria}", "w+" do |pipe|       # removed ------------------

       # edited -------------------------------        IO.popen "java -Djava.awt.headless=true -cp \"#{interface_classpath}\" XmlJasperInterface -o#{output_type} -f#{Dir.getwd}/app/reports/#{report_design} -x#{select_criteria}", mode do |pipe|        # edited -------------------------------

Thanks a lot Denis. That clearly solved my problem.

Karthi kn wrote:

Thanks a lot Denis. That clearly solved my problem.

You're welcome. It feels good to be right now and again :slight_smile:

Regards

Denis

I guess it's something related to XmlJasperinterface (class not found)

there is another place than <RAILSAPP>/app/jasper/lib where I should to copy this file?, or maybe define $CLASSPATH environment variable?, or something I'm missing?

The file should be in /BIN not /LIB

ie. where your appplication is XXXXXX

C:\InstantRails\rails_apps\XXXXXX\app\jasper\bin

Regards

Denis

Denis Mahony wrote:

I guess it's something related to XmlJasperinterface (class not found)

there is another place than <RAILSAPP>/app/jasper/lib where I should to copy this file?, or maybe define $CLASSPATH environment variable?, or something I'm missing?

The file should be in /BIN not /LIB

ie. where your appplication is XXXXXX

C:\InstantRails\rails_apps\XXXXXX\app\jasper\bin

Regards

Denis

Thank you a lot Denis for taking time to answer this

I've just did a mistake writing prior post, my XmlJasperinterface.class file actually is at <RAILSAPP>/app/jasper/bin, and I did also:

export CLASSPATH=<RAILSAPP>/app/jasper/bin

but my result pdf file is still getting 0 bytes

Sorry if did not try achieving this with a pure rubyOnRails application (without using Goldberg) before post here, I'll try that this afternoon because I'm suspecting Goldberg may be asking the report for authentication when it try to get data from <RAILSAPP>/app/views/XXXXX/customer_list

nevertheless, it's almost sure I have a problem with ruby accesing XmlJasperinterface, as the message I recevie from command line attempt states

any comment is welcome, regards Mauricio

but my result pdf file is still getting 0 bytes

...

any comment is welcome, regards Mauricio

Ae you actually getting a PDF file displayed that you can save, with no data (a blank page?) Or are you getting a corruption when the PDF is being written ?

The XML selection query used in the Rails code in the line-

send_doc( render_to_string(:template => ‘accounting/customer_list’, :layout => false), ‘/customer_list_result/invoice_customers/customer’, ‘custrep’, ‘CustomerReport’, ’pdf’)

viz. /customer_list_result/invoice_customers/customer

must match the XML quey used when designing the Report to ensure you do actually select the record/nodes you want to target.

Sorry, I'm not familiar with your development variation :frowning:

Denis

It may be because of the invalid character in the stream. Try to read the stream in binary mode. I mean, Use "w+b" instead of "w+", when you open the pipe using IO.popen().

Karthi kn wrote:

It may be because of the invalid character in the stream. Try to read the stream in binary mode. I mean, Use "w+b" instead of "w+", when you open the pipe using IO.popen().

thank you Karthi, but I'm not using ruby to call XmlJasperInterface, just the java command line

I was able to define CLASSPATH, so the java call it's working now, but with same results that before... XmlJasperInterface.class is giving me a corrupted pdf file, when I try to open it, acrobat says "there was an error opening this document. A file read error has ocurred"

I reviwed the Xpath and it's the same that I set in the report, also update all jar files to IReport3.0

thanks anyway

hi all, and thanks for your concern about my dificulties

I have success running the java command line on my laptop (windows), but not in the server (Fedora C6), in this last one I get an empty pdf (0 bytes), it seems that (in XmlJasperInterface.java) jasperPrint object passed to JasperExportManager is empty or invalid

does anybody has had success doing this work on a linux box?, applied some changes at XmlJasperInterface?

thanks in advance

hi again, finaly it work :slight_smile:

at fedora c6, I'm using these files:

poi-3.0.1-FINAL-20070705.jar jdt-compiler-3.1.1.jar jcommon-1.0.0.jar commons-beanutils-1.7.jar barbecue-1.5-beta1.jar jasperreports-3.0.0.jar jfreechart-1.0.3.jar xalan.jar commons-collections-2.1.jar iReport.jar commons-logging-1.0.2.jar log4j-1.2.9.jar iText-2.1.3.jar

and Java Runtime Environment (JRE) 6 Update 7 (fedora c6 default jre-1.4.2-cgj GNU java doesn't work for me, for upgrading I followed http://aditya-fedoralinux.blogspot.com/2008/08/installing-sun-java-instead-of-open-jdk.html), before I upgrade, system gives me some GTK-WARNING message

for running the java command line first I set CLASSPATH adding these 2 lines to /etc/profile (I think there are better ways but this work for me...)

#CLASSPATH=<RAILSAPP>/app/jasper/bin:<RAILSAPP>/app/jasper/lib/filejar1.jar:<RAILSAPP>/app/jasper/lib/filejar2.jar:<RAILSAPP>/app/jasper/lib/filejarN.jar

#export CLASSPATH

then, to "reload" or something, at prompt

#source /etc/profile

java command line should run

after that, ruby also works...

thank everybody

Mauricio Alcayaga wrote:

thank everybody

I'm glad for your success :slight_smile:

Denis

Herman Jansen wrote:

@Fred Thanks Fred. It works the way you suggested.

@Peter It's based on http://wiki.rubyonrails.org/rails/pages/HowtoIntegrateJasperReports , so it's command line and it's fast enough for me. Where do you think I should put the Wiki description ?

Hi I am new at ruby/rails. I am trying to develop a complete application. Now I am building reports using ireport. I have read http://wiki.rubyonrails.org/rails/pages/HowtoIntegrateJasperReports this instruction. But I didn’t understand this. Can you please give me a guide line by using specific points? Such as :

1. you have to install jasper-rails (gem install jasper-rails) 2. now copy lib files from (…..) to raillsapplicaion/app/jasper/lib folder 3. add these code to the abc controller file 4. put your *.jasper file to the raillsapplicaion/app/reports folder 5. ……. 6. …….

Please help me if possible

mujahid

Hi All

I am using ireport 3.0.0. I am getting the datasource from an xml response which is almost ten MB file. My problem here is if my input is large , ireport is taking hardly 10 minutes to give the output. if i use small response as input then there is no problem. So is there any optimization process are there to overcome these kind of issues.

I am using ireport 3.0.0. I am getting the datasource from an xml response which is almost ten MB file. My problem here is if my input is large , ireport is taking hardly 10 minutes to give the output. if i use small response as input then there is no problem. So is there any optimization process are there to overcome these kind of issues.