abdujaparov Posted October 21, 2009 Share Posted October 21, 2009 Hi,I have a lot of problems with jasper report.I created a report with a subreport.I succed to create the jrxml report.When I try to compile the report I receive only the Main report jasper file and not the other subreport jasper. And I don't know why.These are my files:Main report: <?xml version="1.0" encoding="UTF-8" ?> <!-- Created with iReport - A designer for JasperReports --> <!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> <jasperReport name="Excel" columnCount="1" printOrder="Vertical" orientation="Portrait" pageWidth="595" pageHeight="842" columnWidth="535" columnSpacing="0" leftMargin="30" rightMargin="30" topMargin="20" bottomMargin="20" whenNoDataType="NoPages" isTitleNewPage="false" isSummaryNewPage="false"> <property name="ireport.scriptlethandling" value="0" /> <property name="ireport.encoding" value="UTF-8" /> <import value="java.util.*" /> <import value="net.sf.jasperreports.engine.*" /> <import value="net.sf.jasperreports.engine.data.*" /> <queryString><![CDATA[sELECT TRUNC(SYSDATE) AS DATA FROM DUAL]]></queryString> <field name="DATA" class="java.sql.Timestamp"/> <background> <band height="0" isSplitAllowed="true" > </band> </background> <title> <band height="67" isSplitAllowed="true" > <image evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="1" y="1" width="364" height="66" key="image-1"/> <box></box> <graphicElement stretchType="NoStretch"/> <imageExpression class="java.lang.String"><![CDATA["/findb/sw/fin/java/CreateReportCPPI/reports/logoBancaIMI.jpg"]]></imageExpression> </image> </band> </title> <pageHeader> <band height="133" isSplitAllowed="true" > <staticText> <reportElement mode="Opaque" x="111" y="0" width="424" height="33" forecolor="#000000" key="subscriptionFORM" positionType="Float"/> <box></box> <textElement textAlignment="Center" verticalAlignment="Middle"> <font fontName="Arial" size="16" isUnderline="true"/> </textElement> <text><![CDATA[sUBSCRIPTION FORM]]></text> </staticText> <staticText> <reportElement x="1" y="1" width="109" height="32" key="from"/> <box></box> <textElement textAlignment="Left" verticalAlignment="Bottom"> <font fontName="Arial"/> </textElement> <text><![CDATA[From:]]></text> </staticText> <staticText> <reportElement x="1" y="33" width="135" height="23" key="bancaImiSPA"/> <box></box> <textElement textAlignment="Left" verticalAlignment="Middle"> <font fontName="Arial" pdfFontName="Helvetica-Bold" isBold="true"/> </textElement> <text><![CDATA[bANCA IMI SPA]]></text> </staticText> <staticText> <reportElement x="1" y="77" width="341" height="23" key="telefono1"/> <box></box> <textElement verticalAlignment="Middle"> <font fontName="Arial"/> </textElement> <text><![CDATA[TEL: #39-02.7261.5463(Enrico COTTINI) or .5446 (Paolo FOSCHIANO)]]></text> </staticText> <staticText> <reportElement x="1" y="100" width="341" height="23" key="confirmationTxt"/> <box></box> <textElement verticalAlignment="Middle"> <font fontName="Arial"/> </textElement> <text><![CDATA[PLEASE SEND CONFIRMATIONS TO: #39-02.7261.5217]]></text> </staticText> <staticText> <reportElement x="1" y="54" width="296" height="23" key="staticText-10"/> <box></box> <textElement verticalAlignment="Middle"> <font fontName="Arial" pdfFontName="Helvetica-Bold" isBold="true"/> </textElement> <text><![CDATA[Piazzetta Giordano Dell'Amore, 3 - 20121 - MILANO]]></text> </staticText> </band> </pageHeader> <columnHeader> <band height="0" isSplitAllowed="true" > </band> </columnHeader> <detail> <band height="135" isSplitAllowed="true" > <line direction="TopDown"> <reportElement x="1" y="3" width="534" height="0" key="line-1"/> <graphicElement stretchType="NoStretch"/> </line> <subreport isUsingCache="true"> <reportElement x="1" y="5" width="534" height="126" key="subreport-1"/> <subreportExpression class="java.lang.String"><![CDATA["/findb/sw/fin/java/CreateReportCPPI/reports/subGestore.jrmxl"]]></subreportExpression> </subreport> </band> </detail> <columnFooter> <band height="30" isSplitAllowed="true" > <line direction="TopDown"> <reportElement x="1" y="1" width="534" height="0" key="line-2"/> <graphicElement stretchType="NoStretch"/> </line> </band> </columnFooter> <pageFooter> <band height="224" isSplitAllowed="true" > <staticText> <reportElement x="1" y="1" width="534" height="23" key="subscrptio2"/> <box></box> <textElement textAlignment="Center" verticalAlignment="Middle"> <font fontName="Arial" pdfFontName="Helvetica-Bold" size="12" isBold="true" isUnderline="true"/> </textElement> <text><![CDATA[sUBSCRIPTION FORM]]></text> </staticText> <subreport isUsingCache="true"> <reportElement x="1" y="104" width="534" height="78" key="subreport-2"/> <subreportExpression class="java.lang.String"><![CDATA["/findb/sw/fin/java/CreateReportCPPI/reports/subFondi.jrmxl"]]></subreportExpression> </subreport> <staticText> <reportElement x="1" y="23" width="249" height="23" key="clientDesign"/> <box></box> <textElement verticalAlignment="Middle"> <font fontName="Arial"/> </textElement> <text><![CDATA[Client designation: Banca IMI spa - Strategie Attive]]></text> </staticText> <staticText> <reportElement x="1" y="46" width="59" height="23" key="account"/> <box></box> <textElement verticalAlignment="Middle"> <font fontName="Arial"/> </textElement> <text><![CDATA[Account:]]></text> </staticText> <staticText> <reportElement x="23" y="193" width="146" height="23" key="noDelivery"/> <box></box> <textElement verticalAlignment="Middle"> <font fontName="Arial"/> </textElement> <text><![CDATA[No delivery of certificates.]]></text> </staticText> <staticText> <reportElement x="23" y="81" width="100" height="23" key="nomeFondo-1"/> <box> <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="1.0" lineColor="#000000"/> <bottomPen lineWidth="1.0" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement verticalAlignment="Bottom"> <font fontName="Arial"/> </textElement> <text><![CDATA[Fund Name]]></text> </staticText> <staticText> <reportElement x="123" y="81" width="39" height="23" key="staticText-5"/> <box> <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement verticalAlignment="Bottom"> <font fontName="Arial"/> </textElement> <text><![CDATA[share class]]></text> </staticText> <staticText> <reportElement x="162" y="81" width="74" height="23" key="staticText-6"/> <box> <topPen lineWidth="1.0" lineStyle="Solid"/> <bottomPen lineWidth="1.0" lineStyle="Solid"/> <rightPen lineWidth="1.0" lineStyle="Solid"/> </box> <textElement verticalAlignment="Bottom"> <font fontName="Arial"/> </textElement> <text><![CDATA[iSIN CODE]]></text> </staticText> <staticText> <reportElement x="236" y="81" width="55" height="23" key="staticText-7"/> <box> <pen lineWidth="0.0" lineStyle="Solid"/> <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/> <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement verticalAlignment="Bottom"> <font fontName="Arial"/> </textElement> <text><![CDATA[CASH AMOUNT]]></text> </staticText> <staticText> <reportElement x="291" y="81" width="62" height="23" key="staticText-8"/> <box> <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement verticalAlignment="Bottom"> <font fontName="Arial"/> </textElement> <text><![CDATA[PAYMENT CURRENCY]]></text> </staticText> <staticText> <reportElement x="353" y="81" width="46" height="23" key="staticText-9"/> <box> <topPen lineWidth="1.0" lineColor="#000000"/> <bottomPen lineWidth="1.0" lineColor="#000000"/> <rightPen lineWidth="1.0" lineColor="#000000"/> </box> <textElement verticalAlignment="Bottom"> <font fontName="Arial"/> </textElement> <text><![CDATA[internal Code]]></text> </staticText> </band> </pageFooter> <lastPageFooter> <band height="155" isSplitAllowed="true" > <staticText> <reportElement x="180" y="55" width="59" height="23" key="staticText-2"/> <box></box> <textElement textAlignment="Right" verticalAlignment="Bottom"> <font fontName="Arial"/> </textElement> <text><![CDATA[Milan,]]></text> </staticText> <textField isStretchWithOverflow="false" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="180" y="77" width="57" height="23" key="textField-2"/> <box></box> <textElement> <font/> </textElement> <textFieldExpression class="java.sql.Timestamp"><![CDATA[$F{DATA}]]></textFieldExpression> </textField> <staticText> <reportElement x="330" y="55" width="127" height="23" key="staticText-3"/> <box></box> <textElement textAlignment="Left" verticalAlignment="Bottom"> <font fontName="Arial"/> </textElement> <text><![CDATA[Authorized Signature:]]></text> </staticText> <image evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="331" y="78" width="111" height="50" key="image-2"/> <box></box> <graphicElement stretchType="NoStretch"/> <imageExpression class="java.lang.String"><![CDATA["/findb/sw/fin/java/CreateReportCPPI/reports/firmaCottini.jpg"]]></imageExpression> </image> <staticText> <reportElement x="332" y="130" width="111" height="23" key="staticText-4"/> <box></box> <textElement textAlignment="Center" verticalAlignment="Middle"> <font fontName="Arial"/> </textElement> <text><![CDATA[(Enrico Cottini)]]></text> </staticText> </band> </lastPageFooter> <summary> <band height="131" isSplitAllowed="true" > </band> </summary> </jasperReport> Subreport:<?xml version="1.0" encoding="UTF-8" ?><!-- Created with iReport - A designer for JasperReports --><!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"><jasperReport name="classic" columnCount="1" printOrder="Vertical" orientation="Portrait" pageWidth="535" pageHeight="802" columnWidth="535" columnSpacing="0" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" whenNoDataType="AllSectionsNoDetail" isTitleNewPage="false" isSummaryNewPage="false"> <property name="ireport.scriptlethandling" value="0" /> <property name="ireport.encoding" value="UTF-8" /> <import value="java.util.*" /> <import value="net.sf.jasperreports.engine.*" /> <import value="net.sf.jasperreports.engine.data.*" /> <queryString><![CDATA[sELECT B.NOME_GESTORE AS GESTORE, B.INDIRIZZO1, B.INDIRIZZO2, B.INDIRIZZO3,B.INDIRIZZO4, B.TELEFONO AS TELGESTORE, B.FAX AS FAXGESTOREFROM CPPI_GESTORI BWHERE B.NOME_GESTORE=PIPPO]]></queryString> <field name="GESTORE" class="java.lang.String"/> <field name="INDIRIZZO1" class="java.lang.String"/> <field name="INDIRIZZO2" class="java.lang.String"/> <field name="INDIRIZZO3" class="java.lang.String"/> <field name="INDIRIZZO4" class="java.lang.String"/> <field name="TELGESTORE" class="java.lang.String"/> <field name="FAXGESTORE" class="java.lang.String"/> <background> <band height="0" isSplitAllowed="true" > </band> </background> <title> <band height="0" isSplitAllowed="true" > </band> </title> <pageHeader> <band height="0" isSplitAllowed="true" > </band> </pageHeader> <columnHeader> <band height="0" isSplitAllowed="true" > </band> </columnHeader> <detail> <band height="266" isSplitAllowed="true" > <staticText> <reportElement x="23" y="0" width="162" height="23" key="numberPage"/> <box></box> <textElement verticalAlignment="Middle"> <font fontName="Arial"/> </textElement> <text><![CDATA[Number of Pages (including this):]]></text> </staticText> <staticText> <reportElement x="23" y="23" width="24" height="23" key="to"/> <box></box> <textElement verticalAlignment="Middle"> <font fontName="Arial"/> </textElement> <text><![CDATA[To:]]></text> </staticText> <textField isStretchWithOverflow="true" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="23" y="46" width="134" height="23" key="gestoreField"/> <box></box> <textElement textAlignment="Left" verticalAlignment="Middle"> <font fontName="Arial" pdfFontName="Helvetica-Bold" size="11" isBold="true"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{GESTORE}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="23" y="69" wi Link to comment Share on other sites More sharing options...
gevattertod Posted October 21, 2009 Share Posted October 21, 2009 Try compiling your Subreport (like you did with your Main Report), that you get your subreport.jasper file.Then run your mainReport.So long GevatterTod *this is a signature* Link to comment Share on other sites More sharing options...
Giulio Toffoli Posted October 21, 2009 Share Posted October 21, 2009 With iReport 3.6.0, if subreports can be found by iReport, they are automatically compiled. Giulio Link to comment Share on other sites More sharing options...
abdujaparov Posted October 22, 2009 Author Share Posted October 22, 2009 Hi,I compiled the jrxml subreport.Now I have in the directory /findb/sw/fin/java/CreateReportCPPI/reportsthe reportExcel.jrxmlsubGestore.jrxmlsubFondi.jrxmland in the folder:/findb/sw/fin/java/CreateReportCPPI/build/reportsthe jasper files:Excel.jaspersubGestore.jaspersubFondi.jasperNow I try to create the excel and I receive this error: [java] 0 [main] INFO xml.XmlBeanDefinitionReader - Loading XML bean definitions from URL [file:/findb/sw/fin/lib/jasperreports-3.1.4/demo/fonts/font_bundle.xml] [java] net.sf.jasperreports.engine.JRException: Error loading object from file : /findb/sw/fin/java/CreateReportCPPI/reports/subGestore.jrmxl [java] at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:96) [java] at net.sf.jasperreports.engine.util.JRLoader.loadObjectFromLocation(JRLoader.java:262) [java] at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateSubreport(JRFillSubreport.java:312) [java] at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluate(JRFillSubreport.java:261) [java] at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:275) [java] at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:426) [java] at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:1380) [java] at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:692) [java] at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:255) [java] at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:113) [java] at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:888) [java] at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:791) [java] at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:63) [java] at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:402) [java] at net.sf.jasperreports.engine.JasperFillManager.fillReportToFile(JasperFillManager.java:188) [java] at net.sf.jasperreports.engine.JasperFillManager.fillReportToFile(JasperFillManager.java:94) [java] at CreateReportCPPI.main(CreateReportCPPI.java:113)In the java file I created I receiv the error at the line 113: JasperFillManager.fillReportToFile(fileName, null, conn);Why this problem?Problems with datasource?The queries returns the datas are in the jrxml files.Thanks, bye bye. Link to comment Share on other sites More sharing options...
gevattertod Posted October 22, 2009 Share Posted October 22, 2009 [java] 0 [main] INFO xml.XmlBeanDefinitionReader - Loading XML bean definitions from URL [file:/findb/sw/fin/lib/jasperreports-3.1.4/demo/fonts/font_bundle.xml] [java] net.sf.jasperreports.engine.JRException: Error loading object from file : /findb/sw/fin/java/CreateReportCPPI/reports/subGestore.jrmxliReport can't load the file:/findb/sw/fin/java/CreateReportCPPI/reports/subGestore.jrmxlI would expect that: either it doesn't exist, or the path is wrong. Greets Gevatter *this is a signature* Link to comment Share on other sites More sharing options...
abdujaparov Posted October 23, 2009 Author Share Posted October 23, 2009 Hi,I'm sure the file exists!Now, before filling the main report I execute a filling of the sub report but now I receive this error:java.lang.UnsatisfiedLinkError: Native Library /sw/oracle/10.2/lib32/libocijdbc10.so already loaded in another classloader I don't know the cause of it, if I compile and fill another report composed by only the main report without the subreport all work well but with the subreport I have a lot of problem.What do I do wrong?my java class is: public class CreateReportCPPI { /** * Possibili tasks */ private static final String TASK_FILL = "fill"; private static final String TASK_XLS = "xls"; private static final String TASK_PDF = "pdf"; public static String DB_NAME; public static String DB_USERNAME; public static String DB_PASSWORD; public static String DRIVER; public static String DB_URL; /** * */ public static void main(String[] args) { if(args.length == 0) { usage(); return; } String taskName = args[0]; String fileName = args[1]; String connection = System.getProperty("findb.connection"); if (connection == null) { System.err.println("Stringa di connessione al db non specificata!"); System.exit(1); } String[] tokens = connection.split("\\/"); DB_USERNAME = tokens[0]; DB_PASSWORD = tokens[1].split("\\@")[0]; DB_NAME = tokens[1].split("\\@")[1]; DRIVER = "oracle.jdbc.OracleDriver"; DB_URL = "jdbc:oracle:oci:@"+DB_NAME; try { long start = System.currentTimeMillis(); if (TASK_FILL.equals(taskName)) { Class.forName(DRIVER); Connection conn = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD); System.out.println("****NOME DEL FILE RICEVUTO:" + fileName); JasperFillManager.fillReportToFile(fileName, null, conn); System.err.println("Filling time : " + (System.currentTimeMillis() - start)); } else if (TASK_XLS.equals(taskName)) { File sourceFile = new File(fileName); JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile); File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xls"); JRXlsExporter exporter = new JRXlsExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFile.toString()); exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.TRUE); exporter.exportReport(); System.err.println("XLS creation time : " + (System.currentTimeMillis() - start)); } else if (TASK_PDF.equals(taskName)) { JasperExportManager.exportReportToPdfFile(fileName); System.err.println("PDF creation time : " + (System.currentTimeMillis() - start)); } else { usage(); } } catch (JRException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } /** * Usage */ private static void usage() { System.out.println( "CreateExcelSingleSheet usage:" ); System.out.println( "\tjava CreateExcelSingleSheet task file" ); System.out.println( "\tTasks : fill | xls | pdf" ); } } I call this class 3 times one for the first subreport, one for the second subreport and the last time for the main report.I obtain the correct .jasper files. But when I call this java program for the first subreport filling I receive the errore I paste above.What do I have to do?Thanks, bye bye. Link to comment Share on other sites More sharing options...
gevattertod Posted October 23, 2009 Share Posted October 23, 2009 Honestly I dont know. I just can guess.And I would guess, that you can't call your Driver multiple times.And thats what you are doing, if you execute your class 3 times in the same thread.I would recommend to call your class just ONCE, because the subreport handling is done by iReport. As said above, this is just a guess. Greetz Gevatter *this is a signature* Link to comment Share on other sites More sharing options...
abdujaparov Posted October 23, 2009 Author Share Posted October 23, 2009 Hi,I solved the error but now I don't know how I can generate the excel file.I have subreport1, subreport2, main report.So first of all I need to fill the two subreport.And then I have to fill the main report with some datas and with the subreports.I have the class I paste before. Only that class.Actually I call the class 3 times (one time for earch report).I exepct three jrprint files instead I obtain only one jrprint file named classic.jrprint why?However than I call the class for the main report to obtain the excel file I receive this error:net.sf.jasperreports.engine.JRException: Error loading object from file : /findb/sw/fin/java/CreateReportCPPI/reports/subGestore.jrmxl Now, I don't use iReport. I used iReport only to create the jrxml file. Now I mustn't use iReport.I think that the class is wrong, how can I write the class for this report?where can I find a guide a tutorial o something else of this type?Thanks.Bye bye.Post Edited by abdujaparov at 10/23/2009 09:20 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now