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.
Here is my xml_data param of the pipe.write method
<?xml version="1.0" encoding="UTF-8"?>
<customer_list_result>
<invoice_customers>
smalltown
1
A Nuino
big town
2
3D-Design
Expensivetown
3
International Inc.
</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.
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:
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
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.
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
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
I’ve followed your instructions here and at Peak Obsession, but
no success, or just partial success, my pdf comes 0 bytes
I’m now trying the command line proposed there to get the report, and I
receive the folloing
Exception in thread “main” java.lang.NoClassDefFoundError:
XmlJasperInterface
at gnu.java.lang.MainThread.run(libgcj.so.7rh)
Caused by: java.lang.ClassNotFoundException: XmlJasperInterface not
found in gnu.gcj.runtime.SystemClassLoader{urls=[],
parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
at java.net.URLClassLoader.findClass(libgcj.so.7rh)
at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.7rh)
at java.lang.ClassLoader.loadClass(libgcj.so.7rh)
at java.lang.ClassLoader.loadClass(libgcj.so.7rh)
at gnu.java.lang.MainThread.run(libgcj.so.7rh)
I guess it’s something related to XmlJasperinterface (class not found)
there is another place than /app/jasper/lib where I should to
copy this file?, or maybe define $CLASSPATH environment variable?, or
something I’m missing?
BTW: I’m developing in a FedoraC6, with Apache, also using goldberg
(integrated site design for ruby on rails, due to this, I did some
changes to path’s at /app/models/document.rb, but test if its geting the
right files and it is)
I guess it’s something related to XmlJasperinterface (class not found)
there is another place than /app/jasper/lib where I should to
copy this file?, or maybe define $CLASSPATH environment variable?, or
something I’m missing?
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-
I guess it’s something related to XmlJasperinterface (class not found)
there is another place than /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 /app/jasper/bin, and I did also:
export CLASSPATH=/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
/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
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 ?
.
.
.
Sorry, I’m not familiar with your development variation
Denis
thank you Denis
I’m receiving a “file” with 0 bytes (absolutely blank page, no source
code), I can’t save it
it seems that I first must be sure that java command line works
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
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().