Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

iReports - using an XML file as input

  • 19-02-2008 8:10pm
    #1
    Registered Users, Registered Users 2 Posts: 582 ✭✭✭


    Hi I've been trying to use iReports and having problems.

    As I understand it iReports can extract data from the tree/node type structure of an XML file.

    The ultimate aim is to use iReports & JasperReports with Ruby on Rails, to generate PDF reports from a database.

    As a qiki tutorial i've followed :

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

    As an initial test I used this file ;

    dotted line just for display/separation here


    <?xml version="1.0" encoding="UTF-8"?>
    <customer_list_result>
    <invoice_customers>
    <customer>
    <id type="integer">711</id>
    <name>3D-Design</name>
    <city>Bigtown</city>
    </customer>
    <customer>
    <id type="integer">496</id>
    <name>A Nuino</name>
    <city>Smalltown</city>
    </customer>
    <customer>
    <id type="integer">368</id>
    <name>International Inc.</name>
    <city>Expensivetown</city>
    </customer>
    </invoice_customers>
    </customer_lookup_result>

    dotted line just for display/separation here

    and use of iReport XML data source requires one to define an XPATH2 spec.
    OK ! Looks like it should be ;

    /customer_list_result/invoice_customers/customer.

    I cannot get iReports to display any elements in the FIELDS node. It clearly does not regard the above file as conforming to it's required XML spec.
    A field selection panel should pop up on the right side ...
    Could the tutorial I'm following be wrong , or incomplete in some respect?

    Does iReports expect a particular verion of XML ?
    And does it need to be defined within the file by a header ?


    Lot's of head scratching going on.....

    This following file does present a field list and allows a pdf report to be created. I got this file content from an XML specification site

    dotted line just for display/separation here

    <?xml version="1.0"?>
    <ROOT xmlns:sql="urn:schemas-microsoft-com:xml-sql">
    <row
    acctnumber="417459"
    transactionnumber="1072600"
    ordersalespersonname="Adam Sawvell"
    thudate="08/16/2007"
    industryname="Musicians Services"
    industrycode="0610"
    inches="11.5000"
    netprice="300.00"
    countad="1"
    firstname="Sean Jordan"
    classtype="Music"/>
    <row acctnumber="413733"
    transactionnumber="1074116"
    ordersalespersonname="Adam Sawvell"
    thudate="08/16/2007"
    industryname="Roommates"
    industrycode="0305"
    inches=".4580"
    netprice="10.00"
    countad="1"
    firstname="Tracy Nguyen"
    classtype="Roommate"/>
    </ROOT>

    dotted line just for display/separation here
    Tried to follow this site also ........lost in a trail of specs....

    http://www.w3.org/TR/REC-xml/

    Has anybody experience of iReports ?

    A. :confused:


Comments

  • Registered Users, Registered Users 2 Posts: 995 ✭✭✭cousin_borat


    Tip #1 use the
    , [html] or [php] tags when youre pasting in code.
    
    Also 
    
    [code]
    <?xml version="1.0" encoding="UTF-8"?>
    [B]<customer_list_result>[/B]
    <invoice_customers>
    <customer>
    <id type="integer">711</id>
    <name>3D-Design</name>
    <city>Bigtown</city>
    </customer>
    <customer>
    <id type="integer">496</id>
    <name>A Nuino</name>
    <city>Smalltown</city>
    </customer>
    <customer>
    <id type="integer">368</id>
    <name>International Inc.</name>
    <city>Expensivetown</city>
    </customer>
    </invoice_customers>
    [B]</customer_lookup_result>[/B]
    

    On first inspection the top and bottom tags highlighted in bold don't match. Change the bottom tag to <customer_list_result>


  • Registered Users, Registered Users 2 Posts: 582 ✭✭✭Anchises


    damn ! why did I not spot that ...........

    The saga goes on ....


  • Registered Users, Registered Users 2 Posts: 582 ✭✭✭Anchises


    Hmmm.....
    Edited file as suggested ...

    Now says ;

    Selected Nodes:3
    when the read fields button is clicked, but still no field selector popped up ...

    A.


  • Registered Users, Registered Users 2 Posts: 582 ✭✭✭Anchises


    BTW
    spotted this on iReport site...
    I'm using version 2.0.4
    I wonder if that last bug listed is actually fixed for all data source types ie XML ?


    Complete Changelog.txt related to this version

    14/01/2008 12.00 gt Updated to JR 2.0.4
    13/01/2008 12.00 gt Fixed a problem with the list of query executers
    13/01/2008 12.00 gt Fixed Bug 10334 "Read Fields" button doesn't work consistently)


    A.


  • Registered Users, Registered Users 2 Posts: 995 ✭✭✭cousin_borat


    Anchises wrote: »
    Hmmm.....
    Edited file as suggested ...

    Now says ;

    Selected Nodes:3
    when the read fields button is clicked, but still no field selector popped up ...

    A.

    I don't know the syntax in question. However if you look inside the <customer> field there are three attribute tags id, name, city
    <customer>
    <id type="integer">711</id>
    <name>3D-Design</name>
    <city>Bigtown</city>
    </customer>
    


    Try something like
    /customer_list_result/invoice_customers/customer/name

    see if that gets displayed as a field selector

    if that works try something like

    /customer_list_result/invoice_customers/customer/*

    Its been awhile since I've looked at XML parsing I'm afraid


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 582 ✭✭✭Anchises


    Tried ;

    /customer_list_result/invoice_customers/customer/name
    The final name comes up in bold , but still no joy.
    Use of the * , still no joy... :(

    I suspect the the bug whereby the [field read button] function was fixed, may not have fixed it for XML....:eek:

    XML would not be the preferred method of using iReport, but Ruby on Rails/JasperReports require it for PDF

    I'm going to leave it for now -too late in the night .........
    Tomorrow I climb the mountain again.. :)

    Thanks a lot
    A.

    PS ... yes I should have used tags in the thread as you suggested ...


  • Registered Users, Registered Users 2 Posts: 582 ✭✭✭Anchises


    Success at last ...

    Using as input Northwind.xml - got from iReports site tutorial...
    It works as expected....

    Now to figure out why my apparently identically formatted XML file would not work......

    We're down at the nuts & bolts level here...........;)

    A.


  • Registered Users, Registered Users 2 Posts: 582 ✭✭✭Anchises


    I've finally got some degree of success.
    I can consistently generate XML from within Ruby and launch the code to create the PDF in Jasper ...
    Adobe reader comes up and complains - file does not start with '%PDF-'.

    However the problem is the Java interface , failing with this :

    Exception in thread "main" java.lang.NoClassDefFoundError: C:/InstantRails/......./app/jasper/bin/XmlJasperInterface

    Caused by: java.lang.ClassNotFoundException:
    C:.InstantRails/.........jasper.bin.XmlJasperInterface

    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoaderloadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadclass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)

    Does this look like a path error ..........libs not found ??

    I wont say I'm puzzled !
    I'm lost ......... :)

    Java amazes me with it's complexity...

    installed :
    jdk1.6.0_05
    Jre1.6.0_02
    Jre1.6.0_03
    Jre1.6.0_05

    Win XP SP2
    Ruby On Rails ver 1.7
    iReports 2.0.4
    JasperReports 2.0.4

    A.


  • Closed Accounts Posts: 2 srogers


    I'm trying to get JasperReports going from the command line as described at

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

    and I'm getting the same error mentioned above:

    Exception in thread "main" java.lang.NoClassDefFoundError: XmlJasperInterface
    Caused by: java.lang.ClassNotFoundException: XmlJasperInterface

    If anyone has any insights, please post - thanks


  • Registered Users, Registered Users 2 Posts: 582 ✭✭✭Anchises


    I had some degree of success finally with this interface. I've since abandoned it and amnow using Ruport.

    The error you are getting is probably due to an inability to find the correct java JAR files.

    You are using it from the command prompt ? Why ?
    I've not tried that, since it was easier to get it working as defined on that page .

    Are you sure you copied ALL the required Java files to the Reports folder in your RAILs_APP/application folder ?

    The code on the page had (has? ) a no. of bugs - and was giving me a path error , because it could not find the jars.

    Also the lib files you copy across to ruby MUST be the ones installed in iRepport when the report is designed.

    I could maybe email you a zip of a tiny working application ? I'm assuming you are using WIN ?


    Denis


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 582 ✭✭✭Anchises


    There's a long thread on :

    http://www.ruby-forum.com/topic/139453

    that might help.

    A.


  • Registered Users, Registered Users 2 Posts: 582 ✭✭✭Anchises


    BTW......just in case...

    The command prompt line expects you to insert the full paths and names of ALL the JAR files you will need to at the ;............" part of the line .....

    But you know that :)

    java -Djava.awt.headless=true -cp "C:/project/app/jasper/bin;C:/project/app/jasper/lib/commons-logging-1.0.2.jar;C:/project/app/jasper/lib/itext-1.3.1.jar;......" XmlJasperInterface -opdf -fC:/project/app/reports/CustomerReport.jasper -x/customer_list_result/invoice_customers/customer < customer.xml > custrep.pdf

    A.


  • Closed Accounts Posts: 2 srogers


    Hi - thanks for the replies. My specific problem with the error above came from having the XmlJasperInterface.class file in the wrong place. Once I fixed that, it ran and generated a PDF with only the title and some other bits. Eventually, I figured out that I have to pick "compile" in iReport to generate an up-to-date .jasper file (thought it did that automatically, but no). Once I got the freshly compiled .jasper file, then it worked.

    I'm setting it up to run from the command line because I have a back-end report runner in my system. Rather than generating the PDF in the loop and sending it back to the user, the request goes to a queue, and the user can see when it's ready (some reports are pretty large and take a while to run). I'm trying this out as an alternative to Ruport, primarily because it takes so long to create all the fancy formatting in Ruport vs. iReport. If we go with this, I'll change it so the java process won't have to be re-launched every time, but it's good enough for a prototype we can use to see how we like Jasper and iReport workflow. This way, I can run my existing Ruport reports and the new Jasper reports side by side.

    Another thing I noticed is that when you're getting an invalid PDF message from the PDF viewer, it can be because there's an error in the switches, and XmlJasperInterface is dumping it's error message and help text into the output file. Just try opening the PDF in a text reader to see what's in there.

    BTW - I'm developing on OS X and deploying to CentOS.


  • Closed Accounts Posts: 2 gusantor


    srogers wrote: »
    Hi - thanks for the replies. My specific problem with the error above came from having the XmlJasperInterface.class file in the wrong place. Once I fixed that, it ran and generated a PDF with only the title and some other bits....

    I'm setting it up to run from the command line because I have a back-end report runner in my system. Rather than generating the PDF in the loop and sending it back to the user, the request goes to a queue...
    .
    .
    .
    BTW - I'm developing on OS X and deploying to CentOS.

    Hi all

    when I try command line:

    java -Djava.awt.headless=true -cp "<RAILS_APP>app/jasper/bin;<RAILS_APP>app/jasper/lib/poi-3.0.1-FINAL-20070705.jar;<RAILS_APP>app/jasper/lib/jdt-compiler-3.1.1.jar;<RAILS_APP>app/jasper/lib/jcommon-1.0.0.jar;<RAILS_APP>app/jasper/lib/commons-beanutils-1.7.jar;<RAILS_APP>app/jasper/lib/barbecue-1.1.jar;<RAILS_APP>app/jasper/lib/jasperreports-2.0.2.jar;<RAILS_APP>app/jasper/lib/jfreechart-1.0.0.jar;<RAILS_APP>app/jasper/lib/xalan.jar;<RAILS_APP>app/jasper/lib/commons-collections-2.1.jar;<RAILS_APP>app/jasper/lib/itext-1.3.1.jar;<RAILS_APP>app/jasper/lib/iReport.jar;<RAILS_APP>app/jasper/lib/commons-logging-1.0.2.jar;<RAILS_APP>app/jasper/lib/log4j-1.2.9.jar" XmlJasperInterface -opdf -f<RAILS_APP>app/reports/testoXML.jasper -x/customer_list_result/invoice_customers/customer < <RAILS_APP>app/reports/customer_list.xml > custrep.pdf

    I'm getting the following error message:

    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)


    since it's states that NoClassDefFoundError, I'm guessing where should I put this file?, which was the right place for you?

    I did try also:

    export CLASSPATH=<RAILS_APP>/app/jasper/lib:<RAILS_APP>/app/jasper/bin

    having no success

    thanks in advance


  • Closed Accounts Posts: 2 gusantor


    hi again, finaly it work :)

    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 (and it does)

    after that, ruby also works...

    thank everybody


  • Registered Users, Registered Users 2 Posts: 582 ✭✭✭Anchises


    :) - Good

    Anchises

    AKA Denis


Advertisement